Class Scenario.When.EventResult<E>
java.lang.Object
org.springframework.modulith.test.Scenario.When.EventResult<E>
- Enclosing class:
- Scenario.When<T>
The result of an expected event publication.
- Author:
- Oliver Drotbohm
-
Constructor Summary
ConstructorsConstructorDescriptionEventResult(Class<E> type, Function<PublishedEvents.TypedPublishedEvents<E>, PublishedEvents.TypedPublishedEvents<E>> filtered, @Nullable org.springframework.modulith.test.Scenario.When.ExecutionResult<?, T> previousResult) Creates a newScenario.When.EventResultfor the given type and filter. -
Method Summary
Modifier and TypeMethodDescriptionMatches events that satisfy the givenPredicate.<S> Scenario.When<T>.EventResult<E>matchingMapped(Function<E, S> extractor, Predicate<? super S> filter) <S> Scenario.When<T>.EventResult<E>matchingMappedValue(Function<E, S> extractor, @Nullable S value) Matches events that extracting the given value using the givenFunction.voidVerifies that no event of the given specification arrives within the configured wait time (seeScenario.When.andWaitAtMost(Duration)).voidnotToArriveAndVerify(Consumer<T> consumer) Verifies that no event of the given specification arrives within the configured wait time (seeScenario.When.andWaitAtMost(Duration)) and invokes the given consumer with the result created by the stimulus afterwards.voidtoArrive()Awaits an event of the given specification to arrive.voidtoArriveAndAssert(BiConsumer<PublishedEventsAssert.PublishedEventAssert<? super E>, T> consumer) Expects the events previously specified to arrive and additionally assert thePublishedEventsAssertfor the captured event and original stimulus result.voidtoArriveAndAssert(Consumer<PublishedEventsAssert.PublishedEventAssert<? super E>> consumer) Expects the events previously specified to arrive and additionally assert thePublishedEventsAssertfor the captured event.voidtoArriveAndVerify(BiConsumer<E, T> consumer) Awaits an event of the given specification to arrive and invokes the given consumer with it as well as the result created by the stimulus.voidtoArriveAndVerify(Consumer<E> consumer) Awaits an event of the given specification to arrive and invokes the given consumer with it.
-
Constructor Details
-
EventResult
EventResult(Class<E> type, Function<PublishedEvents.TypedPublishedEvents<E>, PublishedEvents.TypedPublishedEvents<E>> filtered, @Nullable org.springframework.modulith.test.Scenario.When.ExecutionResult<?, T> previousResult) Creates a newScenario.When.EventResultfor the given type and filter.- Parameters:
type- must not be null.filtered- must not be null.previousResult- a potentially previously calculated result.
-
-
Method Details
-
matching
Matches events that satisfy the givenPredicate.- Parameters:
filter- must not be null.- Returns:
- will never be null.
-
matchingMapped
@CheckReturnValue public <S> Scenario.When<T>.EventResult<E> matchingMapped(Function<E, S> extractor, Predicate<? super S> filter) - Type Parameters:
S- the type of the extracted value.- Parameters:
extractor- must not be null.filter- must not be null.- Returns:
- will never be null.
-
matchingMappedValue
@CheckReturnValue public <S> Scenario.When<T>.EventResult<E> matchingMappedValue(Function<E, S> extractor, @Nullable S value) Matches events that extracting the given value using the givenFunction.- Type Parameters:
S- the type of the extracted value.- Parameters:
extractor- must not be null.value- can be null.- Returns:
- will never be null.
-
toArrive
public void toArrive()Awaits an event of the given specification to arrive. -
notToArrive
public void notToArrive()Verifies that no event of the given specification arrives within the configured wait time (seeScenario.When.andWaitAtMost(Duration)). Note that, as the absence of an event can only be established by waiting, a successful invocation always takes the full wait time.- Since:
- 2.2
-
notToArriveAndVerify
Verifies that no event of the given specification arrives within the configured wait time (seeScenario.When.andWaitAtMost(Duration)) and invokes the given consumer with the result created by the stimulus afterwards.- Parameters:
consumer- must not be null.- Since:
- 2.2
- See Also:
-
toArriveAndVerify
Awaits an event of the given specification to arrive and invokes the given consumer with it.- Parameters:
consumer- must not be null.
-
toArriveAndVerify
Awaits an event of the given specification to arrive and invokes the given consumer with it as well as the result created by the stimulus.- Parameters:
consumer- must not be null.
-
toArriveAndAssert
public void toArriveAndAssert(Consumer<PublishedEventsAssert.PublishedEventAssert<? super E>> consumer) Expects the events previously specified to arrive and additionally assert thePublishedEventsAssertfor the captured event.- Parameters:
consumer- must not be null.
-
toArriveAndAssert
public void toArriveAndAssert(BiConsumer<PublishedEventsAssert.PublishedEventAssert<? super E>, T> consumer) Expects the events previously specified to arrive and additionally assert thePublishedEventsAssertfor the captured event and original stimulus result.- Parameters:
consumer- must not be null.
-