@@ -196,6 +196,73 @@ public void testLoadConfigWithIncrementalSync() throws Exception {
196196 remoteConfigLongPollService .stopLongPollingRefresh ();
197197 }
198198
199+ @ Test
200+ public void testMergeConfigurations () throws Exception {
201+ String key1 = "key1" ;
202+ String value1 = "value1" ;
203+ String anotherValue1 = "anotherValue1" ;
204+
205+ String key3 = "key3" ;
206+ String value3 = "value3" ;
207+ Map <String , String > previousConfigurations = ImmutableMap .of (key1 , value1 ,key3 ,value3 );
208+
209+ List <ConfigurationChange > configurationChanges =new ArrayList <>();
210+ configurationChanges .add (new ConfigurationChange (key1 , anotherValue1 , ConfigurationChangeType .MODIFIED ));
211+ String key2 = "key2" ;
212+ String value2 = "value2" ;
213+ configurationChanges .add (new ConfigurationChange (key2 , value2 , ConfigurationChangeType .ADDED ));
214+ configurationChanges .add (new ConfigurationChange (key3 , null , ConfigurationChangeType .DELETED ));
215+
216+ RemoteConfigRepository remoteConfigRepository = new RemoteConfigRepository (someNamespace );
217+ Map <String , String > result =remoteConfigRepository .mergeConfigurations (previousConfigurations , configurationChanges );
218+
219+ assertEquals (2 , result .size ());
220+ assertEquals (anotherValue1 , result .get (key1 ));
221+ assertEquals (value2 , result .get (key2 ));
222+ }
223+ @ Test
224+ public void testMergeConfigurationWithPreviousConfigurationsIsNULL () throws Exception {
225+ String key1 = "key1" ;
226+ String value1 = "value1" ;
227+
228+ String key3 = "key3" ;
229+ String value3 = "value3" ;
230+
231+ Map <String , String > previousConfigurations = ImmutableMap .of (key1 , value1 ,key3 ,value3 );
232+
233+
234+ RemoteConfigRepository remoteConfigRepository = new RemoteConfigRepository (someNamespace );
235+ Map <String , String > result =remoteConfigRepository .mergeConfigurations (previousConfigurations , null );
236+
237+ assertEquals (2 , result .size ());
238+ assertEquals (value1 , result .get (key1 ));
239+ assertEquals (value3 , result .get (key3 ));
240+ }
241+
242+ @ Test
243+ public void testMergeConfigurationWithChangesIsNULL () throws Exception {
244+ String key1 = "key1" ;
245+ String value1 = "value1" ;
246+ String anotherValue1 = "anotherValue1" ;
247+
248+ String key3 = "key3" ;
249+ String value3 = "value3" ;
250+
251+ List <ConfigurationChange > configurationChanges =new ArrayList <>();
252+ configurationChanges .add (new ConfigurationChange (key1 , anotherValue1 , ConfigurationChangeType .MODIFIED ));
253+ String key2 = "key2" ;
254+ String value2 = "value2" ;
255+ configurationChanges .add (new ConfigurationChange (key2 , value2 , ConfigurationChangeType .ADDED ));
256+ configurationChanges .add (new ConfigurationChange (key3 , null , ConfigurationChangeType .DELETED ));
257+
258+ RemoteConfigRepository remoteConfigRepository = new RemoteConfigRepository (someNamespace );
259+ Map <String , String > result =remoteConfigRepository .mergeConfigurations (null , configurationChanges );
260+
261+ assertEquals (2 , result .size ());
262+ assertEquals (anotherValue1 , result .get (key1 ));
263+ assertEquals (value2 , result .get (key2 ));
264+ }
265+
199266 @ Test
200267 public void testLoadConfigWithOrderedProperties () throws Exception {
201268 String someKey = "someKey" ;
0 commit comments