Class TestDropwizardAppExtension.Builder
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.jupiter.ext.TestDropwizardAppExtension.Builder
-
- Enclosing class:
- TestDropwizardAppExtension
public static class TestDropwizardAppExtension.Builder extends java.lang.Object
Builder used for manual extension registration (TestDropwizardAppExtension.forApp(Class)
).
-
-
Constructor Summary
Constructors Constructor Description Builder(java.lang.Class<? extends io.dropwizard.Application> app)
-
Method Summary
-
-
-
Method Detail
-
config
public TestDropwizardAppExtension.Builder config(java.lang.String configPath)
Same asTestDropwizardApp.config()
.- Parameters:
configPath
- configuration file path- Returns:
- builder instance for chained calls
-
configOverrides
public TestDropwizardAppExtension.Builder configOverrides(java.lang.String... values)
Same asTestDropwizardApp.configOverride()
. Multiple calls will not be merged!- Parameters:
values
- overriding configuration values in "key: value" format- Returns:
- builder instance for chained calls
- See Also:
for specifying objects directly
-
configOverrides
@SafeVarargs public final <T extends io.dropwizard.testing.ConfigOverride & ConfigurablePrefix> TestDropwizardAppExtension.Builder configOverrides(T... values)
DirectConfigOverride
objects support. In most cases, it is simpler to use pure strings withconfigOverrides(String...)
. Direct objects may be useful when provided value must be lazy evaluated (e.g. it is obtained from some other junit extension).IMPORTANT: provided values must implement
ConfigurablePrefix
interface so guicey could insert correct prefix, used by current test (required for parallel tests as all config overrides eventually stored in system properties).May be called multiple times (values appended).
- Parameters:
values
- overriding configuration values- Returns:
- builder instance for chained calls
- See Also:
for an exmample of required implementation
,for supplier shortcut
-
configOverride
public TestDropwizardAppExtension.Builder configOverride(java.lang.String key, java.util.function.Supplier<java.lang.String> supplier)
Shortcut forconfigOverrides(ConfigOverride[])
. Registers config override with a supplier. Useful for values with delayed resolution (e.g. provided by some other extension).- Parameters:
key
- configuration keysupplier
- value supplier- Returns:
- builder instance for chained calls
-
hooks
public TestDropwizardAppExtension.Builder hooks(java.lang.Class<? extends GuiceyConfigurationHook> hooks)
Same asTestDropwizardApp.hooks()
. May be called multiple times.Anonymous hooks could be declared with a static field:
@EnableHook static GuiceyConfigurationHook hook = builder -> builder.disableExtension( Something.class)
. All such fields will be detected automatically and hooks registered. Hooks declared in base test classes are also counted.- Parameters:
hooks
- hook classes to use- Returns:
- builder instance for chained calls
-
hooks
public TestDropwizardAppExtension.Builder hooks(GuiceyConfigurationHook... hooks)
Has no annotation equivalent. May be used for quick configurations with lambda:
May be called multiple times..hooks(builder -> builder.modules(new DebugModule()))
Also, anonymous hooks could be declared with a static field:
@EnableHook static GuiceyConfigurationHook hook = builder -> builder.disableExtension( Something.class)
. All such fields will be detected automatically and hooks registered. Hooks declared in base test classes are also counted.- Parameters:
hooks
- hook instances (may be lambdas)- Returns:
- builder instance for chained calls
-
randomPorts
public TestDropwizardAppExtension.Builder randomPorts(boolean randomPorts)
Same asTestDropwizardApp.randomPorts()
.- Parameters:
randomPorts
- true to use random ports- Returns:
- builder instance for chained calls
-
randomPorts
public TestDropwizardAppExtension.Builder randomPorts()
Shortcut forrandomPorts(boolean)
.- Returns:
- builder instance for chained calls
-
restMapping
public TestDropwizardAppExtension.Builder restMapping(java.lang.String mapping)
Same asTestDropwizardApp.restMapping()
.- Parameters:
mapping
- rest mapping path- 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
-
-