Package org.axonframework.test.saga
Interface WhenState
- All Known Subinterfaces:
ContinuedGivenState
- All Known Implementing Classes:
SagaTestFixture
public interface WhenState
Interface providing an API to methods in the "when" state of the fixture execution. Unlike the methods in the
"given" state, these methods record the behavior of the Sagas involved for validation.
- Since:
- 2.1.1
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionwhenAggregate(String aggregateIdentifier) Use this method to indicate that an aggregate with given identifier should publish certain events, while recording the outcome.whenPublishingA(Object event) Use this method to indicate an application is published, while recording the outcome.whenPublishingA(Object event, Map<String, ?> metaData) Use this method to indicate an application is published with given additionalmetaData, while recording the outcome.whenTimeAdvancesTo(Instant newDateTime) Mimic an elapsed time with no relevant activity for the Saga.whenTimeElapses(Duration elapsedTime) Mimic an elapsed time with no relevant activity for the Saga.
-
Method Details
-
whenAggregate
Use this method to indicate that an aggregate with given identifier should publish certain events, while recording the outcome. In contrast to theFixtureConfiguration.givenAggregate(String)given} andContinuedGivenState.andThenAggregate(String)andThen} methods, this method will start recording activity on the EventBus and CommandBus. Can be chained to build natural sentences:
whenAggregate(someIdentifier).publishes(anEvent)Note that if you inject resources usingFixtureConfiguration.registerResource(Object), you may need to reset them yourself if they are manipulated by the Saga in the "given" stage of the test.- Parameters:
aggregateIdentifier- The identifier of the aggregate the events should appear to come from- Returns:
- an object that allows registration of the actual events to send
-
whenPublishingA
Use this method to indicate an application is published, while recording the outcome. Note that if you inject resources usingFixtureConfiguration.registerResource(Object), you may need to reset them yourself if they are manipulated by the Saga in the "given" stage of the test.- Parameters:
event- the event to publish- Returns:
- an object allowing you to verify the test results
-
whenPublishingA
Use this method to indicate an application is published with given additionalmetaData, while recording the outcome. Note that if you inject resources usingFixtureConfiguration.registerResource(Object), you may need to reset them yourself if they are manipulated by the Saga in the "given" stage of the test.- Parameters:
event- the event to publishmetaData- The meta data to attach to the event- Returns:
- an object allowing you to verify the test results
-
whenTimeElapses
Mimic an elapsed time with no relevant activity for the Saga. If any Events are scheduled to be published within this time frame, they are published. All activity by the Saga on the CommandBus and EventBus (meaning that scheduled events are excluded) is recorded. Note that if you inject resources usingFixtureConfiguration.registerResource(Object), you may need to reset them yourself if they are manipulated by the Saga in the "given" stage of the test.- Parameters:
elapsedTime- The amount of time to elapse- Returns:
- an object allowing you to verify the test results
-
whenTimeAdvancesTo
Mimic an elapsed time with no relevant activity for the Saga. If any Events are scheduled to be published within this time frame, they are published. All activity by the Saga on the CommandBus and EventBus (meaning that scheduled events are excluded) is recorded. Note that if you inject resources usingFixtureConfiguration.registerResource(Object), you may need to reset them yourself if they are manipulated by the Saga in the "given" stage of the test.- Parameters:
newDateTime- The time to advance the clock to- Returns:
- an object allowing you to verify the test results
-