public static class MockApp.Builder extends Object implements WorkerAppBuilder<MockApp>
| Modifier and Type | Method and Description |
|---|---|
<I,M extends I> |
addMockSingleton(M mockedService,
Class<I> baseClass) |
<I> MockApp.Builder |
addMockSingleton(MockSingleton<I> mockSingleton) |
MockApp.Builder |
addModule(com.google.inject.Module module) |
MockApp |
build()
Returns a newly-created
MockApp based on the contents of the Builder. |
MockApp |
buildPartial()
Returns a newly-created partial
MockApp for use in unit tests. |
MockApp.Builder |
clear()
Resets the state of this builder.
|
MockApp.Builder |
disableErrorOnServiceLeaks() |
MockApp.Builder |
enableBindingOverrides() |
MockApp.Builder |
enableServiceGraph(net.spals.appbuilder.graph.model.ServiceGraphFormat graphFormat) |
org.slf4j.Logger |
getLogger()
Returns the value that will be returned by
App.getLogger(). |
String |
getName()
Returns the value that will be returned by
App.getName(). |
com.typesafe.config.Config |
getServiceConfig()
Returns the value that will be returned by
App.getServiceConfig(). |
com.google.inject.Injector |
getServiceInjector()
Returns the value that will be returned by
App.getServiceInjector(). |
MockApp.Builder |
mapLogger(java.util.function.UnaryOperator<org.slf4j.Logger> mapper)
Replaces the value to be returned by
App.getLogger() by applying mapper to
it and using the result. |
MockApp.Builder |
mapName(java.util.function.UnaryOperator<String> mapper)
Replaces the value to be returned by
App.getName() by applying mapper to it
and using the result. |
MockApp.Builder |
mapServiceConfig(java.util.function.UnaryOperator<com.typesafe.config.Config> mapper)
Replaces the value to be returned by
App.getServiceConfig() by applying mapper to it and using the result. |
MockApp.Builder |
mapServiceInjector(java.util.function.UnaryOperator<com.google.inject.Injector> mapper)
Replaces the value to be returned by
App.getServiceInjector() by applying mapper to it and using the result. |
MockApp.Builder |
mergeFrom(MockApp.Builder template)
Copies values from the given
Builder. |
MockApp.Builder |
mergeFrom(MockApp value)
Sets all property values using the given
MockApp as a template. |
MockApp.Builder |
setLogger(org.slf4j.Logger logger)
Sets the value to be returned by
App.getLogger(). |
MockApp.Builder |
setName(String name)
Sets the value to be returned by
App.getName(). |
MockApp.Builder |
setServiceConfig(com.typesafe.config.Config serviceConfig)
Sets the value to be returned by
App.getServiceConfig(). |
MockApp.Builder |
setServiceConfigFromClasspath(String serviceConfigFileName) |
MockApp.Builder |
setServiceInjector(com.google.inject.Injector serviceInjector)
Sets the value to be returned by
App.getServiceInjector(). |
MockApp.Builder |
setServiceScan(net.spals.appbuilder.config.service.ServiceScan serviceScan) |
public Builder(Class<?> testClazz)
public <I> MockApp.Builder addMockSingleton(MockSingleton<I> mockSingleton)
public <I,M extends I> MockApp.Builder addMockSingleton(M mockedService, Class<I> baseClass)
public MockApp.Builder addModule(com.google.inject.Module module)
addModule in interface WorkerAppBuilder<MockApp>public MockApp.Builder disableErrorOnServiceLeaks()
disableErrorOnServiceLeaks in interface WorkerAppBuilder<MockApp>public MockApp.Builder enableBindingOverrides()
enableBindingOverrides in interface WorkerAppBuilder<MockApp>public MockApp.Builder enableServiceGraph(net.spals.appbuilder.graph.model.ServiceGraphFormat graphFormat)
enableServiceGraph in interface WorkerAppBuilder<MockApp>public MockApp.Builder setServiceConfig(com.typesafe.config.Config serviceConfig)
App.getServiceConfig().setServiceConfig in interface WorkerAppBuilder<MockApp>Builder objectpublic MockApp.Builder setServiceConfigFromClasspath(String serviceConfigFileName)
setServiceConfigFromClasspath in interface WorkerAppBuilder<MockApp>public MockApp.Builder setServiceScan(net.spals.appbuilder.config.service.ServiceScan serviceScan)
setServiceScan in interface WorkerAppBuilder<MockApp>public MockApp build()
MockApp based on the contents of the Builder.build in interface WorkerAppBuilder<MockApp>public MockApp.Builder setLogger(org.slf4j.Logger logger)
App.getLogger().Builder objectNullPointerException - if logger is nullpublic MockApp.Builder mapLogger(java.util.function.UnaryOperator<org.slf4j.Logger> mapper)
App.getLogger() by applying mapper to
it and using the result.Builder objectNullPointerException - if mapper is null or returns nullIllegalStateException - if the field has not been setpublic org.slf4j.Logger getLogger()
App.getLogger().IllegalStateException - if the field has not been setpublic MockApp.Builder setName(String name)
App.getName().Builder objectNullPointerException - if name is nullpublic MockApp.Builder mapName(java.util.function.UnaryOperator<String> mapper)
App.getName() by applying mapper to it
and using the result.Builder objectNullPointerException - if mapper is null or returns nullIllegalStateException - if the field has not been setpublic String getName()
App.getName().IllegalStateException - if the field has not been setpublic MockApp.Builder mapServiceConfig(java.util.function.UnaryOperator<com.typesafe.config.Config> mapper)
App.getServiceConfig() by applying mapper to it and using the result.Builder objectNullPointerException - if mapper is null or returns nullIllegalStateException - if the field has not been setpublic com.typesafe.config.Config getServiceConfig()
App.getServiceConfig().IllegalStateException - if the field has not been setpublic MockApp.Builder setServiceInjector(com.google.inject.Injector serviceInjector)
App.getServiceInjector().Builder objectNullPointerException - if serviceInjector is nullpublic MockApp.Builder mapServiceInjector(java.util.function.UnaryOperator<com.google.inject.Injector> mapper)
App.getServiceInjector() by applying mapper to it and using the result.Builder objectNullPointerException - if mapper is null or returns nullIllegalStateException - if the field has not been setpublic com.google.inject.Injector getServiceInjector()
App.getServiceInjector().IllegalStateException - if the field has not been setpublic MockApp.Builder mergeFrom(MockApp value)
MockApp as a template.public MockApp.Builder mergeFrom(MockApp.Builder template)
Builder. Does not affect any properties not set on the
input.public MockApp.Builder clear()
public MockApp buildPartial()
MockApp for use in unit tests. State checking will not
be performed. Unset properties will throw an UnsupportedOperationException when
accessed via the partial object.
Partials should only ever be used in tests. They permit writing robust test cases that won't fail if this type gains more application-level constraints (e.g. new required fields) in future. If you require partially complete values in production code, consider using a Builder.
Copyright © 2018. All rights reserved.