Class Scenario.When<T>
java.lang.Object
org.springframework.modulith.test.Scenario.When<T>
- Enclosing class:
- Scenario
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
-
Constructor Summary
ConstructorDescriptionWhen
(BiFunction<TransactionOperations, ApplicationEventPublisher, T> stimulus, Consumer<T> cleanup, Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) -
Method Summary
Modifier and TypeMethodDescriptionandCleanup
(Runnable runnable) andCleanup
(Consumer<T> consumer) andWaitAtMost
(Duration duration) Configures theScenario
to 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.<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 givenPredicate
to determine whether the value is conclusive.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
-
andCleanup
Registers the givenRunnable
as cleanup callback to always run after completion of theScenario
, no matter the outcome of its execution (error or success).- Parameters:
runnable
- must not be null.- Returns:
- will never be null.
-
andCleanup
Registers the givenConsumer
as cleanup callback to always run after completion of theScenario
, no matter the outcome of its execution (error or success).- Parameters:
consumer
- must not be null.- Returns:
- will never be null.
-
andWaitAtMost
Configures theScenario
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
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. By default, a non-null value would indicate success, except forOptional
s, in which case we'd check for the presence of a value andbooleans
, for which we accept true as conclusive signal. For more control about the result matching, useandWaitForStateChange(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 givenPredicate
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:
-