Class TestDropwizardAppExtension.Builder

    • Constructor Detail

      • Builder

        public Builder​(java.lang.Class<? extends io.dropwizard.Application> app)
    • Method Detail

      • configOverrides

        @SafeVarargs
        public final <T extends io.dropwizard.testing.ConfigOverride & ConfigurablePrefixTestDropwizardAppExtension.Builder configOverrides​(T... values)
        Direct ConfigOverride objects support. In most cases, it is simpler to use pure strings with configOverrides(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 for configOverrides(ConfigOverride[]). Registers config override with a supplier. Useful for values with delayed resolution (e.g. provided by some other extension).
        Parameters:
        key - configuration key
        supplier - value supplier
        Returns:
        builder instance for chained calls
      • hooks

        public TestDropwizardAppExtension.Builder hooks​(java.lang.Class<? extends GuiceyConfigurationHook> hooks)
        Same as TestDropwizardApp.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:
        
         .hooks(builder -> builder.modules(new DebugModule()))
         
        May be called multiple times.

        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
      • 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