Class Scenario
java.lang.Object
org.springframework.modulith.test.Scenario
A DSL to define integration testing scenarios for application modules. A 
Scenario starts with a stimulus on
 the system, usually a component invocation (see stimulate(Function) or event publication (see
 publish(Object...)) and a definition of the expected outcome. That can be a state change observed by
 invoking application module components (see Scenario.When.andWaitForStateChange(Supplier)) or another event being
 published (see Scenario.When.andWaitForEventOfType(Class)), concluded by additional verifications.
 
 Scenario can be used as JUnit test method parameter in ApplicationModuleTests.
- Author:
- Oliver Drotbohm
- See Also:
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructorsConstructorDescriptionScenario(TransactionTemplate transactionTemplate, ApplicationEventPublisher publisher, AssertablePublishedEvents events) Creates a newScenariofor the givenTransactionTemplate,ApplicationEventPublisherandAssertablePublishedEvents.
- 
Method SummaryModifier and TypeMethodDescriptionPublishes the given event.Publishes the event provided by the givenSupplier.(package private) ScenariosetDefaultCustomizer(Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) Extension hook to allow registration of a global customizer.Stimulates the system by executing the givenRunnable.Stimulate the system using the givenTransactionOperationsandApplicationEventPublisher.<S> Scenario.When<S>Stimulate the system using the givenTransactionOperationsandApplicationEventPublisherand produce a result.<S> Scenario.When<S>stimulate(Function<TransactionOperations, S> function) Stimulates the system using the given function providing access to theTransactionOperationsand keeping the supplied value around for later verification.<S> Scenario.When<S>Stimulates the system using the givenSupplierand keeping the supplied value around for later verification.
- 
Constructor Details- 
ScenarioScenario(TransactionTemplate transactionTemplate, ApplicationEventPublisher publisher, AssertablePublishedEvents events) Creates a newScenariofor the givenTransactionTemplate,ApplicationEventPublisherandAssertablePublishedEvents.- Parameters:
- transactionTemplate- must not be null.
- publisher- must not be null.
- events- must not be null.
 
 
- 
- 
Method Details- 
publishPublishes the given event. The event will be published in a transaction to make sure that transactional event listeners are invoked as well.- Parameters:
- event- must not be null.
- Returns:
- will never be null.
 
- 
publishPublishes the event provided by the givenSupplier. The event will be published in a transaction to make sure that transactional event listeners are invoked as well.- Parameters:
- event- must not be null.
- Returns:
- will never be null.
 
- 
stimulateStimulates the system by executing the givenRunnable.- Parameters:
- runnable- must not be null.
- Returns:
- will never be null.
 
- 
stimulateStimulates the system using the givenSupplierand keeping the supplied value around for later verification.- Type Parameters:
- S- the type of the value returned by the stimulus.
- Parameters:
- supplier- must not be null.
- Returns:
- will never be null.
- See Also:
 
- 
stimulateStimulates the system using the given function providing access to theTransactionOperationsand keeping the supplied value around for later verification.- Type Parameters:
- S- the type of the value returned by the stimulus.
- Parameters:
- function- must not be null.
- Returns:
- will never be null.
 
- 
stimulatepublic Scenario.When<Void> stimulate(BiConsumer<TransactionOperations, ApplicationEventPublisher> stimulus) Stimulate the system using the givenTransactionOperationsandApplicationEventPublisher. Usually a method on some application service or event publication is triggered.- Parameters:
- stimulus- must not be null.
- Returns:
- will never be null.
 
- 
stimulatepublic <S> Scenario.When<S> stimulate(BiFunction<TransactionOperations, ApplicationEventPublisher, S> stimulus) Stimulate the system using the givenTransactionOperationsandApplicationEventPublisherand produce a result. Usually a method on some application service or event publication is triggered.- Type Parameters:
- S- the type of the result.
- Parameters:
- stimulus- must not be null.
- Returns:
- will never be null.
 
- 
setDefaultCustomizerScenario setDefaultCustomizer(Function<org.awaitility.core.ConditionFactory, org.awaitility.core.ConditionFactory> customizer) Extension hook to allow registration of a global customizer. If none configured we will fall back toFunction.identity().- Parameters:
- customizer- must not be null.
- See Also:
 
 
-