Search in sources :

Example 1 with Credentials

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());
}
Also used : FakeClock(net.morimekta.testing.time.FakeClock) Credentials(net.morimekta.test.providence.config.Credentials) Before(org.junit.Before)

Example 2 with Credentials

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"));
}
Also used : Database(net.morimekta.test.providence.config.Database) Credentials(net.morimekta.test.providence.config.Credentials) Test(org.junit.Test)

Aggregations

Credentials (net.morimekta.test.providence.config.Credentials)2 Database (net.morimekta.test.providence.config.Database)1 FakeClock (net.morimekta.testing.time.FakeClock)1 Before (org.junit.Before)1 Test (org.junit.Test)1