Class TestDropwizardAppExtension.Builder<C extends io.dropwizard.core.Configuration>
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.jupiter.ext.conf.ExtensionBuilder<C,TestDropwizardAppExtension.Builder<C>,ru.vyarus.dropwizard.guice.test.jupiter.ext.TestDropwizardAppExtension.Config>
-
- ru.vyarus.dropwizard.guice.test.jupiter.ext.TestDropwizardAppExtension.Builder<C>
-
- Type Parameters:
C- configuration type (resolved automatically by application class)
- Enclosing class:
- TestDropwizardAppExtension
public static class TestDropwizardAppExtension.Builder<C extends io.dropwizard.core.Configuration> extends ExtensionBuilder<C,TestDropwizardAppExtension.Builder<C>,ru.vyarus.dropwizard.guice.test.jupiter.ext.TestDropwizardAppExtension.Config>
Builder used for manual extension registration (TestDropwizardAppExtension.forApp(Class)).
-
-
Field Summary
-
Fields inherited from class ru.vyarus.dropwizard.guice.test.jupiter.ext.conf.ExtensionBuilder
cfg
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestDropwizardAppExtension.Builder<C>config(java.lang.String configPath)Same asTestDropwizardApp.config().TestDropwizardAppExtensioncreate()Creates extension.TestDropwizardAppExtension.Builder<C>randomPorts()Shortcut forrandomPorts(boolean).TestDropwizardAppExtension.Builder<C>randomPorts(boolean randomPorts)Same asTestDropwizardApp.randomPorts().TestDropwizardAppExtension.Builder<C>restMapping(java.lang.String mapping)Same asTestDropwizardApp.restMapping().TestDropwizardAppExtension.Builder<C>setup(java.lang.Class<? extends TestEnvironmentSetup>... support)Environment support object is the simplest way to prepare additional objects for test (like database) and apply configuration overrides.TestDropwizardAppExtension.Builder<C>setup(TestEnvironmentSetup... support)Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides.-
Methods inherited from class ru.vyarus.dropwizard.guice.test.jupiter.ext.conf.ExtensionBuilder
clientFactory, config, configModifiers, configModifiers, configOverride, configOverride, configOverrideByExtension, configOverrideByExtension, configOverrides, configOverrides, debug, disableDefaultExtensions, hooks, hooks, injectOnce, reuseApplication, with
-
-
-
-
Constructor Detail
-
Builder
public Builder(java.lang.Class<? extends io.dropwizard.core.Application<C>> app)
Create builder.- Parameters:
app- application class
-
-
Method Detail
-
config
public TestDropwizardAppExtension.Builder<C> config(java.lang.String configPath)
Same asTestDropwizardApp.config().- Parameters:
configPath- configuration file path- Returns:
- builder instance for chained calls
-
randomPorts
public TestDropwizardAppExtension.Builder<C> randomPorts(boolean randomPorts)
Same asTestDropwizardApp.randomPorts().- Parameters:
randomPorts- true to use random ports- Returns:
- builder instance for chained calls
-
randomPorts
public TestDropwizardAppExtension.Builder<C> randomPorts()
Shortcut forrandomPorts(boolean).- Returns:
- builder instance for chained calls
-
restMapping
public TestDropwizardAppExtension.Builder<C> restMapping(java.lang.String mapping)
Same asTestDropwizardApp.restMapping().- Parameters:
mapping- rest mapping path- Returns:
- builder instance for chained calls
-
setup
@SafeVarargs public final TestDropwizardAppExtension.Builder<C> setup(java.lang.Class<? extends TestEnvironmentSetup>... support)
Environment support object is the simplest way to prepare additional objects for test (like database) and apply configuration overrides. Provided classes would be instantiated with the default constructor.To avoid confusion with guicey hooks: setup object required to prepare test environment before test (and apply required configurations) whereas hooks is a general mechanism for application customization (not only in tests).
Anonymous implementation could be simply declared as field:
@EnableSetup static TestEnvironmentSetup ext = ext -> ext.configOverrides("foo:1"). Non-static fields may be used only when extension is registered with non-static field (static fields would be also counted in this case). All annotated fields will be detected automatically and objects registered. Fields declared in base test classes are also counted.- Parameters:
support- support object classes- Returns:
- builder instance for chained calls
-
setup
public TestDropwizardAppExtension.Builder<C> setup(TestEnvironmentSetup... support)
Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides.To avoid confusion with guicey hooks: setup object required to prepare test environment before test (and apply required configurations) whereas hooks is a general mechanism for application customization (not only in tests).
Anonymous implementation could be simply declared as field:
@EnableSetup static TestEnvironmentSetup ext = ext -> ext.configOverrides("foo:1"). Non-static fields may be used only when extension is registered with non-static field (static fields would be also counted in this case). All annotated fields will be detected automatically and objects registered. Fields declared in base test classes are also counted.- Parameters:
support- support object instances- Returns:
- builder instance for chained calls
-
create
public TestDropwizardAppExtension create()
Creates extension.Note that extension must be assigned to static field! Extension instance does not provide additional methods so use field and parameter injections as with annotation extension declaration.
- Returns:
- extension instance
-
-