use of net.morimekta.providence.config.util.TestConfigSupplier in project providence by morimekta.
the class ProvidenceConfigSupplierTest method testParentConfigUpdatesPropagaing.
@Test
public void testParentConfigUpdatesPropagaing() throws IOException {
TestConfigSupplier<Database, Database._Field> parent = new TestConfigSupplier<>(Database.builder().setUri("foo").build());
File bar = writeContentTo("config.Database { driver = \"bar\" }", tmp.newFile("bar.config"));
SimpleTypeRegistry registry = new SimpleTypeRegistry();
registry.registerRecursively(Database.kDescriptor);
parser = new ProvidenceConfigParser(registry, false);
ProvidenceConfigSupplier<Database, Database._Field> config = new ProvidenceConfigSupplier<>(bar, parent, watcher, parser, clock);
assertThat(config.get(), is(Database.builder().setUri("foo").setDriver("bar").build()));
ConfigListener<Database, Database._Field> listener = mock(ConfigListener.class);
config.addListener(listener);
parent.testUpdate(Database.builder().setUri("fish").build());
verify(listener).onConfigChange(Database.builder().setUri("fish").setDriver("bar").build());
reset(listener);
config.removeListener(listener);
parent.testUpdate(Database.builder().build());
verifyZeroInteractions(listener);
}
Aggregations