Class Scenario.When<T>

java.lang.Object
org.springframework.modulith.test.Scenario.When<T>
Enclosing class:
Scenario

public class Scenario.When<T> extends Object
  • Constructor Details

  • Method Details

    • andCleanup

      public Scenario.When<T> andCleanup(Runnable runnable)
      Registers the given Runnable as cleanup callback to always run after completion of the Scenario, no matter the outcome of its execution (error or success).
      Parameters:
      runnable - must not be null.
      Returns:
      will never be null.
    • andCleanup

      public Scenario.When<T> andCleanup(Consumer<T> consumer)
      Registers the given Consumer as cleanup callback to always run after completion of the Scenario, no matter the outcome of its execution (error or success).
      Parameters:
      consumer - must not be null.
      Returns:
      will never be null.
    • andWaitAtMost

      public Scenario.When<T> andWaitAtMost(Duration duration)
      Configures the Scenario to wait for at most the given duration for an event of the subsequent specification to arrive.
      Parameters:
      duration - must not be null.
      Returns:
      will never be null.
    • customize

      public Scenario.When<T> customize(Function<org.awaitility.core.ConditionFactory,org.awaitility.core.ConditionFactory> customizer)
      Customize the execution of the scenario. The given customizer will be added to the default one registered via a ScenarioCustomizer. In other words, multiple invocations will replace registrations made in previous calls but always be chained after the default customizations registered.
      Parameters:
      customizer - must not be null.
      Returns:
      will never be null.
    • forEventOfType

      public <E> Scenario.When<T>.EventResult<E> forEventOfType(Class<E> type)
      Alternative to andWaitForEventOfType(Class) for better readability if execution customizations have been applied before.
      Type Parameters:
      E - the type of the event.
      Parameters:
      type - must not be null.
      Returns:
      will never be null.
      See Also:
    • forStateChange

      public <S> Scenario.When<T>.StateChangeResult<S> forStateChange(Supplier<S> supplier)
      Alternative to andWaitForStateChange(Supplier) for better readability if execution customizations have been applied before.
      Type Parameters:
      S - the type of the state change result
      Parameters:
      supplier - must not be null.
      Returns:
      will never be null.
      See Also:
    • forStateChange

      public <S> Scenario.When<T>.StateChangeResult<S> forStateChange(Supplier<S> supplier, Predicate<? super S> acceptanceCriteria)
      Alternative to andWaitForStateChange(Supplier, Predicate) for better readability if execution customizations have been applied before.
      Type Parameters:
      S - the type of the state change result
      Parameters:
      supplier - must not be null.
      acceptanceCriteria - must not be null.
      Returns:
      will never be null.
      See Also:
    • andWaitForEventOfType

      public <E> Scenario.When<T>.EventResult<E> andWaitForEventOfType(Class<E> type)
      Expects an event of the given type to arrive. Use API on the returned Scenario.When.EventResult to specify more detailed expectations and conclude those with a call a flavor of Scenario.When.EventResult.toArrive().
      Type Parameters:
      E - the type of the event.
      Parameters:
      type - must not be null.
      Returns:
      will never be null.
      See Also:
    • andWaitForStateChange

      public <S> Scenario.When<T>.StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier)
      Expects a particular state change on the module to produce a result. By default, a non-null value would indicate success, except for Optionals, in which case we'd check for the presence of a value and booleans, for which we accept true as conclusive signal. For more control about the result matching, use andWaitForStateChange(Supplier, Predicate).
      Type Parameters:
      S - the type of the result.
      Parameters:
      supplier - must not be null.
      Returns:
      will never be null.
      See Also:
    • andWaitForStateChange

      public <S> Scenario.When<T>.StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier, Predicate<? super S> acceptanceCriteria)
      Expects a particular state change on the module to produce a result and uses the given Predicate to determine whether the value is conclusive.
      Type Parameters:
      S - the type of the result for the state change
      Parameters:
      supplier - must not be null.
      acceptanceCriteria - must not be null.
      Returns:
      will never be null.
      See Also: