Search in sources :

Example 1 with LoggingFactory

use of io.dropwizard.logging.LoggingFactory in project dropwizard by dropwizard.

the class ConfiguredCommandTest method canUseCustomConfigurationFactory.

@SuppressWarnings("unchecked")
@Test
void canUseCustomConfigurationFactory() throws Exception {
    Configuration configuration = mock(Configuration.class);
    LoggingFactory loggingFactory = mock(LoggingFactory.class);
    ConfigurationFactory<Configuration> factory = Mockito.mock(ConfigurationFactory.class);
    when(factory.build()).thenReturn(configuration);
    when(configuration.getLoggingFactory()).thenReturn(loggingFactory);
    bootstrap.setConfigurationFactoryFactory((klass, validator, objectMapper, propertyPrefix) -> factory);
    assertThat(command.getConfiguration()).isNull();
    command.run(bootstrap, namespace);
    assertThat(command.getConfiguration()).isEqualTo(configuration);
    Mockito.verify(factory).build();
}
Also used : LoggingFactory(io.dropwizard.logging.LoggingFactory) Configuration(io.dropwizard.Configuration) Test(org.junit.jupiter.api.Test)

Aggregations

Configuration (io.dropwizard.Configuration)1 LoggingFactory (io.dropwizard.logging.LoggingFactory)1 Test (org.junit.jupiter.api.Test)1