use of net.morimekta.test.providence.config.Credentials in project providence by morimekta.
the class OverrideConfigSupplierTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() {
clock = new FakeClock();
base = new TestConfigSupplier<>(clock, Database.builder().setUri("http://hostname:9057/path").setDriver("driver").setCredentials(new Credentials("username", "complicated password that no one guesses")).build());
}
use of net.morimekta.test.providence.config.Credentials in project providence by morimekta.
the class OverrideConfigSupplierTest method testSupplier.
@Test
public void testSupplier() throws IOException {
OverrideConfigSupplier<Database, Database._Field> supplier = new OverrideConfigSupplier<>(clock, base, ImmutableMap.of("credentials.password", "password", "uri", "undefined"), true);
Database instance = supplier.get();
assertThat(supplier.get(), is(sameInstance(instance)));
// it was reset.
assertThat(instance.getUri(), is(nullValue()));
assertThat(instance.getDriver(), is("driver"));
assertThat(instance.getCredentials(), is(not(nullValue())));
assertThat(instance.getCredentials().getUsername(), is("username"));
// it was updated.
assertThat(instance.getCredentials().getPassword(), is("password"));
base.testUpdate(Database.builder().setUri("http://hostname:9057/path").setDriver("otherDriver").setCredentials(new Credentials("username", "complicated password that no one guesses")).build());
// updating the base updates the result.
assertThat(supplier.get(), is(not(sameInstance(instance))));
instance = supplier.get();
assertThat(supplier.get(), is(sameInstance(instance)));
assertThat(supplier.configTimestamp(), is(clock.millis()));
// it was reset.
assertThat(instance.getUri(), is(nullValue()));
assertThat(instance.getDriver(), is("otherDriver"));
assertThat(instance.getCredentials(), is(not(nullValue())));
assertThat(instance.getCredentials().getUsername(), is("username"));
// it was updated.
assertThat(instance.getCredentials().getPassword(), is("password"));
}
Aggregations