ConfigurationChangeDetector { protected boolean changed(MapPropertySource left, MapPropertySource right) { if (left == right) { return false; } if (left == null || right == null) { return true; } Map<String, Object> leftMap = left.getSource(); Map<String, Object> rightMap = right.getSource(); return !Objects.equals(leftMap, rightMap); } ConfigurationChangeDetector(ConfigurableEnvironment environment, ConfigReloadProperties properties,
			KubernetesClient kubernetesClient, ConfigurationUpdateStrategy strategy); @PreDestroy void shutdown(); void reloadProperties();  }
@Test public void testChangedTwoNulls() { boolean changed = stub.changed(null, (MapPropertySource) null); Assert.assertFalse(changed); }
@Test public void testChangedLeftNullRightNonNull() { MapPropertySource right = new MapPropertySource("rightNonNull", Collections.emptyMap()); boolean changed = stub.changed(null, right); Assert.assertTrue(changed); }
@Test public void testChangedLeftNonNullRightNull() { MapPropertySource left = new MapPropertySource("leftNonNull", Collections.emptyMap()); boolean changed = stub.changed(left, null); Assert.assertTrue(changed); }
@Test public void testChangedEqualMaps() { Object value = new Object(); Map<String, Object> leftMap = new HashMap<>(); leftMap.put("key", value); Map<String, Object> rightMap = new HashMap<>(); rightMap.put("key", value); MapPropertySource left = new MapPropertySource("left", leftMap); MapPropertySource right = new MapPropertySource("right", rightMap); boolean changed = stub.changed(left, right); Assert.assertFalse(changed); }
@Test public void testChangedNonEqualMaps() { Object value = new Object(); Map<String, Object> leftMap = new HashMap<>(); leftMap.put("key", value); leftMap.put("anotherKey", value); Map<String, Object> rightMap = new HashMap<>(); rightMap.put("key", value); MapPropertySource left = new MapPropertySource("left", leftMap); MapPropertySource right = new MapPropertySource("right", rightMap); boolean changed = stub.changed(left, right); Assert.assertTrue(changed); }
@Test public void testChangedListsDifferentSizes() { List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", Collections.emptyMap())); List<MapPropertySource> right = Collections.emptyList(); boolean changed = stub.changed(left, right); Assert.assertFalse(changed); }
@Test public void testChangedListSameSizesButNotEqual() { Object value = new Object(); Map<String, Object> leftMap = new HashMap<>(); leftMap.put("key", value); Map<String, Object> rightMap = new HashMap<>(); leftMap.put("anotherKey", value); List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", leftMap)); List<MapPropertySource> right = Collections.singletonList(new MapPropertySource("two", rightMap)); boolean changed = stub.changed(left, right); Assert.assertTrue(changed); }
@Test public void testChangedListSameSizesEqual() { Object value = new Object(); Map<String, Object> leftMap = new HashMap<>(); leftMap.put("key", value); Map<String, Object> rightMap = new HashMap<>(); leftMap.put("key", value); List<MapPropertySource> left = Collections.singletonList(new MapPropertySource("one", leftMap)); List<MapPropertySource> right = Collections.singletonList(new MapPropertySource("two", rightMap)); boolean changed = stub.changed(left, right); Assert.assertTrue(changed); }