public interface FixtureConfiguration
Modifier and Type | Method and Description |
---|---|
org.joda.time.DateTime |
currentTime()
Returns the time as "known" by the fixture.
|
GivenAggregateEventPublisher |
givenAggregate(Object aggregateIdentifier)
Use this method to indicate that an aggregate with given identifier published certain events.
|
ContinuedGivenState |
givenAPublished(Object event)
Indicates that the given
applicationEvent has been published in the past. |
WhenState |
givenNoPriorActivity()
Indicates that no relevant activity has occurred in the past.
|
<T> T |
registerCommandGateway(Class<T> gatewayInterface)
Creates a Command Gateway for the given
gatewayInterface and registers that as a resource. |
<T> T |
registerCommandGateway(Class<T> gatewayInterface,
T stubImplementation)
Creates a Command Gateway for the given
gatewayInterface and registers that as a resource. |
void |
registerResource(Object resource)
Registers the given
resource . |
void |
setCallbackBehavior(CallbackBehavior callbackBehavior)
Sets the instance that defines the behavior of the Command Bus when a command is dispatched with a callback.
|
void registerResource(Object resource)
resource
. When a Saga is created, all resources are injected on that instance
before any Events are passed onto it.
Note that a CommandBus, EventBus and EventScheduler are already registered as resources, and need not be
registered again.
Also note that you might need to reset the resources manually if you want to isolate behavior during the "when"
stage of the test.resource
- the resource to register.<T> T registerCommandGateway(Class<T> gatewayInterface)
gatewayInterface
and registers that as a resource. The
gateway will dispatch commands on the Command Bus contained in this Fixture, so that you can validate commands
using FixtureExecutionResult.expectDispatchedCommandsEqualTo(Object...)
and FixtureExecutionResult.expectDispatchedCommandsMatching(org.hamcrest.Matcher)
.
Note that you need to use setCallbackBehavior(org.axonframework.test.utils.CallbackBehavior)
to defined
the behavior of commands when expecting return values. Alternatively, you can use registerCommandGateway(Class, Object)
to define behavior using a stub implementation.T
- The gateway typegatewayInterface
- The interface describing the gateway<T> T registerCommandGateway(Class<T> gatewayInterface, T stubImplementation)
gatewayInterface
and registers that as a resource. The
gateway will dispatch commands on the Command Bus contained in this Fixture, so that you can validate commands
using FixtureExecutionResult.expectDispatchedCommandsEqualTo(Object...)
and FixtureExecutionResult.expectDispatchedCommandsMatching(org.hamcrest.Matcher)
.
The behavior of the created gateway is defined by the given stubImplementation
, if not null.
Dispatched Commands are still recorded for verification. Note that only commands executed in the "when" phase
are recorded, while the stub implementation may record activity during the "given" phase as well.T
- The gateway typegatewayInterface
- The interface describing the gatewaystubImplementation
- The stub or mock implementation defining behavior of the gatewayvoid setCallbackBehavior(CallbackBehavior callbackBehavior)
callbackBehavior
- The instance deciding to how the callback should be invoked.GivenAggregateEventPublisher givenAggregate(Object aggregateIdentifier)
andThenAggregate(someIdentifier).published(someEvents)
aggregateIdentifier
- The identifier of the aggregate the events should appear to come fromContinuedGivenState givenAPublished(Object event)
applicationEvent
has been published in the past. This event is sent to the
associated sagas.event
- The event to publishWhenState givenNoPriorActivity()
org.joda.time.DateTime currentTime()
Copyright © 2010-2014. All Rights Reserved.