org.axonframework.test.saga
Interface WhenState

All Known Subinterfaces:
ContinuedGivenState
All Known Implementing Classes:
AnnotatedSagaTestFixture

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
 WhenAggregateEventPublisher whenAggregate(Object aggregateIdentifier)
          Use this method to indicate that an aggregate with given identifier should publish certain events, while recording the outcome.
 FixtureExecutionResult whenPublishingA(Object event)
          Use this method to indicate an application is published, while recording the outcome.
 FixtureExecutionResult whenTimeAdvancesTo(org.joda.time.DateTime newDateTime)
          Mimic an elapsed time with no relevant activity for the Saga.
 FixtureExecutionResult whenTimeElapses(org.joda.time.Duration elapsedTime)
          Mimic an elapsed time with no relevant activity for the Saga.
 

Method Detail

whenAggregate

WhenAggregateEventPublisher whenAggregate(Object aggregateIdentifier)
Use this method to indicate that an aggregate with given identifier should publish certain events, while recording the outcome. In contrast to the FixtureConfiguration.givenAggregate(Object) given} and ContinuedGivenState.andThenAggregate(Object) 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 using FixtureConfiguration.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

FixtureExecutionResult whenPublishingA(Object event)
Use this method to indicate an application is published, while recording the outcome.

Note that if you inject resources using FixtureConfiguration.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

whenTimeElapses

FixtureExecutionResult whenTimeElapses(org.joda.time.Duration elapsedTime)
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 using FixtureConfiguration.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

FixtureExecutionResult whenTimeAdvancesTo(org.joda.time.DateTime newDateTime)
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 using FixtureConfiguration.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


Copyright © 2010-2016. All Rights Reserved.