Class AbstractProjectGenerationTester<SELF extends AbstractProjectGenerationTester<SELF>>

java.lang.Object
io.spring.initializr.generator.test.project.AbstractProjectGenerationTester<SELF>
Type Parameters:
SELF - concrete type of the tester
Direct Known Subclasses:
ProjectAssetTester, ProjectGeneratorTester

public abstract class AbstractProjectGenerationTester<SELF extends AbstractProjectGenerationTester<SELF>> extends Object
Base tester for project generation.
Author:
Stephane Nicoll
  • Constructor Details

  • Method Details

    • newInstance

      protected abstract SELF newInstance(Map<Class<?>, Supplier<?>> beanDefinitions, Consumer<ProjectGenerationContext> contextInitializer, Consumer<MutableProjectDescription> descriptionCustomizer)
      Create a new instance with the given state.
      Parameters:
      beanDefinitions - the bean definitions
      contextInitializer - the context initializer
      descriptionCustomizer - the description customizer
      Returns:
      a new instance
    • withBean

      public <T> SELF withBean(Class<T> beanType, Supplier<T> beanDefinition)
      Register a bean.
      Type Parameters:
      T - the type of the bean
      Parameters:
      beanType - the type of the bean
      beanDefinition - the supplier of the bean
      Returns:
      a new instance
    • withDirectory

      public SELF withDirectory(Path directory)
      Generate projects in a temporary directory within the given directory.
      Parameters:
      directory - the parent directory
      Returns:
      a new instance
    • withIndentingWriterFactory

      public SELF withIndentingWriterFactory()
      Register an IndentingWriterFactory that indents with four spaces.
      Returns:
      a new instance
    • withConfiguration

      public SELF withConfiguration(Class<?>... configurationClasses)
      Register the given configuration classes.
      Parameters:
      configurationClasses - the configuration classes
      Returns:
      a new instance
    • withContextInitializer

      public SELF withContextInitializer(Consumer<ProjectGenerationContext> context)
      Add a context initializer.
      Parameters:
      context - the context initializer
      Returns:
      a new instance
    • withDescriptionCustomizer

      public SELF withDescriptionCustomizer(Consumer<MutableProjectDescription> description)
      Add a description customizer.
      Parameters:
      description - the description customizer
      Returns:
      a new instance
    • invokeProjectGeneration

      protected <T> T invokeProjectGeneration(MutableProjectDescription description, AbstractProjectGenerationTester.ProjectGenerationInvoker<T> invoker)
      Customize the description and invoke the project generation.
      Type Parameters:
      T - the type of the result
      Parameters:
      description - the description
      invoker - the invoker
      Returns:
      the result of the project generation