Class Scenario.When<T>
java.lang.Object
org.springframework.modulith.test.Scenario.When<T>
- Enclosing class:
- Scenario
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclass -
Constructor Summary
ConstructorsConstructorDescriptionWhen(BiFunction<TransactionOperations, ApplicationEventPublisher, T> stimulus, Consumer<T> cleanup, Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) -
Method Summary
Modifier and TypeMethodDescriptionandWaitAtMost(Duration duration) Configures theScenarioto wait for at most the given duration for an event of the subsequent specification to arrive.<E> Scenario.When<T>.EventResult<E>andWaitForEventOfType(Class<E> type) <S> Scenario.When<T>.StateChangeResult<S>andWaitForStateChange(Supplier<S> supplier) Expects a particular state change on the module to produce a result and uses the givenPredicateto determine whether the value is conclusive.<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.customize(Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) <E> Scenario.When<T>.EventResult<E>forEventOfType(Class<E> type) Alternative toandWaitForEventOfType(Class)for better readability if execution customizations have been applied before.<S> Scenario.When<T>.StateChangeResult<S>forStateChange(Supplier<S> supplier) Alternative toandWaitForStateChange(Supplier)for better readability if execution customizations have been applied before.<S> Scenario.When<T>.StateChangeResult<S>forStateChange(Supplier<S> supplier, Predicate<? super S> acceptanceCriteria) Alternative toandWaitForStateChange(Supplier, Predicate)for better readability if execution customizations have been applied before.
-
Constructor Details
-
When
When(BiFunction<TransactionOperations, ApplicationEventPublisher, T> stimulus, Consumer<T> cleanup, Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) - Parameters:
stimulus- must not be null.cleanup- must not be null.customizer- must not be null.
-
-
Method Details
-
andWaitAtMost
Configures theScenarioto 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
Alternative toandWaitForEventOfType(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
Alternative toandWaitForStateChange(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 toandWaitForStateChange(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
- Type Parameters:
E- the type of the event.- Parameters:
type- must not be null.- Returns:
- will never be null.
- See Also:
-
andWaitForStateChange
Expects a particular state change on the module to produce a result and uses the givenPredicateto determine whether the value is conclusive.- 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. By default, a non-null value would indicate success, except forOptionals, in which case we'd check for the presence of a value. For more control about the result matching, useandWaitForStateChange(Supplier, Predicate)- 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:
-