io.paradoxical.common.test.web.modules.MockEnvironmentModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common.test Show documentation
Show all versions of common.test Show documentation
Jersey request correlation and common utils
package io.paradoxical.common.test.web.modules;
import com.google.inject.Module;
import io.dropwizard.setup.Environment;
import io.paradoxical.common.test.guice.OverridableModule;
import lombok.Getter;
import org.mockito.Mockito;
/**
* Can be used to mock out dropwizard environment and auto mock the config class for a dropwizard service
*/
public class MockEnvironmentModule extends OverridableModule {
private final Class configClass;
@Getter
private final T configInstance;
@Getter
private Environment mockEnvironment = Mockito.mock(Environment.class);
public MockEnvironmentModule(Class configClass) {
this.configClass = configClass;
configInstance = Mockito.mock(configClass);
}
public MockEnvironmentModule(T config) {
configClass = (Class) config.getClass();
configInstance = config;
}
@Override
public Class extends Module> getOverridesModule() {
return null;
}
@Override
protected void configure() {
bind(Environment.class).toInstance(mockEnvironment);
bind(configClass).toInstance(configInstance);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy