PropertySourceChangeSupport { public void addChangeListener(BiConsumer<Set<String>, PropertySource> l){ switch(changeSupport){ case SUPPORTED: if(!listeners.contains(l)){ listeners.add(l); } break; case UNSUPPORTED: case IMMUTABLE: default: break; } } PropertySourceChangeSupport(ChangeSupport changeSupport,
                                       PropertySource propertySource); ChangeSupport getChangeSupport(); String getVersion(); void addChangeListener(BiConsumer<Set<String>, PropertySource> l); void removeChangeListener(BiConsumer<Set<String>, PropertySource> l); void removeAllChangeListeners(); long load(Map<String, PropertyValue> properties); PropertyValue getValue(String key); Map<String, PropertyValue> getProperties(); void scheduleChangeMonitor(Supplier<Map<String, PropertyValue>> propertySupplier, long duration, TimeUnit timeUnit); void cancelSchedule();  }
@Test public void addChangeListener() { PropertySource ps = BuildablePropertySource.builder().withName("test"). withSimpleProperty("foo", "bar").build(); PropertySourceChangeSupport support = new PropertySourceChangeSupport(ChangeSupport.SUPPORTED, ps); support.load(ps.getProperties()); BiConsumer<Set<String>, PropertySource> l = mock(BiConsumer.class); support.addChangeListener(l); support.load(Collections.emptyMap()); verify(l).accept(any(), any()); }