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)
      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)
      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: