T
- The type of Aggregate tested in this Fixturepublic class AggregateTestFixture<T> extends Object implements FixtureConfiguration<T>, TestExecutor<T>
FixtureConfiguration
.Constructor and Description |
---|
AggregateTestFixture(Class<T> aggregateType)
Initializes a new given-when-then style test fixture for the given
aggregateType . |
Modifier and Type | Method and Description |
---|---|
TestExecutor<T> |
andGiven(List<?> domainEvents)
Configures the given
domainEvents as the "given" events. |
TestExecutor<T> |
andGiven(Object... domainEvents)
Configures the given
domainEvents as the "given" events. |
TestExecutor<T> |
andGivenCommands(List<?> commands)
Configures the given
commands as the command that will provide the "given" events. |
TestExecutor<T> |
andGivenCommands(Object... commands)
Configures the given
commands as the command that will provide the "given" events. |
TestExecutor<T> |
andGivenCurrentTime(Instant currentTime)
Use this method to indicate a specific moment as the initial current time "known" by the fixture at the start
of the given state.
|
Instant |
currentTime()
Returns the time as "known" by the fixture.
|
CommandBus |
getCommandBus()
Returns the command bus used by this fixture.
|
EventBus |
getEventBus()
Returns the event bus used by this fixture.
|
EventStore |
getEventStore()
Returns the event store used by this fixture.
|
Repository<T> |
getRepository()
Returns the repository used by this fixture.
|
TestExecutor<T> |
given(List<?> domainEvents)
Configures the given
domainEvents as the "given" events. |
TestExecutor<T> |
given(Object... domainEvents)
Configures the given
domainEvents as the "given" events. |
TestExecutor<T> |
givenCommands(List<?> commands)
Configures the given
commands as to execute against the aggregate under test to initiate the given-phase. |
TestExecutor<T> |
givenCommands(Object... commands)
Configures the given
commands as to execute against the aggregate under test to initiate the given-phase. |
TestExecutor<T> |
givenCurrentTime(Instant currentTime)
Use this method to indicate a specific moment as the initial current time "known" by the fixture at the start of
the given state.
|
TestExecutor<T> |
givenNoPriorActivity()
Indicates that no relevant activities like commands or events have occurred in the past.
|
TestExecutor<T> |
givenState(Supplier<T> aggregate)
Sets the aggregate instance as supplied by given
aggregateState as the initial state for a test case. |
protected void |
handleDeadline(ScopeDescriptor aggregateDescriptor,
DeadlineMessage<?> deadlineMessage)
Handles the given
deadlineMessage in the aggregate described by the given aggregateDescriptor . |
FixtureConfiguration<T> |
registerAggregateFactory(AggregateFactory<T> aggregateFactory)
Registers the given
aggregateFactory with the fixture. |
FixtureConfiguration<T> |
registerAnnotatedCommandHandler(Object annotatedCommandHandler)
Registers an
annotatedCommandHandler with this fixture. |
FixtureConfiguration<T> |
registerCommandDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> commandDispatchInterceptor)
Register a
MessageDispatchInterceptor for CommandMessage s which will be invoked before any
command is dispatched on the CommandBus to perform a task specified in the interceptor. |
FixtureConfiguration<T> |
registerCommandHandler(Class<?> payloadType,
MessageHandler<CommandMessage<?>> commandHandler)
Registers a
commandHandler to handle commands of the given commandType with the
command bus used by this fixture. |
FixtureConfiguration<T> |
registerCommandHandler(String commandName,
MessageHandler<CommandMessage<?>> commandHandler)
Registers a
commandHandler to handle commands of the given commandType with the
command bus used by this fixture. |
FixtureConfiguration<T> |
registerCommandHandlerInterceptor(MessageHandlerInterceptor<? super CommandMessage<?>> commandHandlerInterceptor)
Register a
MessageHandlerInterceptor for CommandMessage s which will be invoked before or after
the command has been dispatched on the CommandBus to perform a task specified in the interceptor. |
FixtureConfiguration<T> |
registerCommandTargetResolver(CommandTargetResolver commandTargetResolver)
Registers the
CommandTargetResolver within this fixture. |
FixtureConfiguration<T> |
registerDeadlineDispatchInterceptor(MessageDispatchInterceptor<? super DeadlineMessage<?>> deadlineDispatchInterceptor)
Registers a deadline dispatch interceptor which will always be invoked before a deadline is dispatched
(scheduled) on the
DeadlineManager to perform a task specified in the
interceptor. |
FixtureConfiguration<T> |
registerDeadlineHandlerInterceptor(MessageHandlerInterceptor<? super DeadlineMessage<?>> deadlineHandlerInterceptor)
Registers a deadline handler interceptor which will always be invoked before a deadline is handled to perform a
task specified in the interceptor.
|
FixtureConfiguration<T> |
registerFieldFilter(FieldFilter fieldFilter)
Registers the given
fieldFilter , which is used to define which Fields are used when comparing objects. |
FixtureConfiguration<T> |
registerHandlerDefinition(HandlerDefinition handlerDefinition)
Registers a
HandlerDefinition within this fixture. |
FixtureConfiguration<T> |
registerHandlerEnhancerDefinition(HandlerEnhancerDefinition handlerEnhancerDefinition)
Registers a
HandlerEnhancerDefinition within this fixture. |
FixtureConfiguration<T> |
registerIgnoredField(Class<?> declaringClass,
String fieldName)
Indicates that a field with given
fieldName , which is declared in given declaringClass
is ignored when performing deep equality checks. |
FixtureConfiguration<T> |
registerInjectableResource(Object resource)
Registers a resource that is eligible for injection in handler method (e.g.
|
FixtureConfiguration<T> |
registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Registers a
ParameterResolverFactory within this fixture. |
FixtureConfiguration<T> |
registerRepository(Repository<T> repository)
Registers an arbitrary
repository with the fixture. |
FixtureConfiguration<T> |
registerRepositoryProvider(RepositoryProvider repositoryProvider)
Registers repository provider with the fixture.
|
void |
setReportIllegalStateChange(boolean reportIllegalStateChange)
Sets whether or not the fixture should detect and report state changes that occur outside of Event Handler
methods.
|
FixtureConfiguration<T> |
useStateStorage()
Configures the fixture for state stored aggregates.
|
ResultValidator<T> |
when(Object command)
Dispatches the given command to the appropriate command handler and records all activity in the fixture for
result validation.
|
ResultValidator<T> |
when(Object command,
Map<String,?> metaData)
Dispatches the given command and meta-data to the appropriate command handler and records all
activity in the fixture for result validation.
|
ResultValidator<T> |
whenConstructing(Callable<T> aggregateFactory)
Invokes the given
aggregateFactory expecting an aggregate instance of type T to be returned. |
ResultValidator<T> |
whenInvoking(String aggregateId,
Consumer<T> aggregateSupplier)
Invokes the given
aggregateConsumer after loading an aggregate of type T based on the given
aggregateIdentifier . |
ResultValidator<T> |
whenThenTimeAdvancesTo(Instant newPointInTime)
Deprecated.
|
ResultValidator<T> |
whenThenTimeElapses(Duration elapsedTime)
Deprecated.
|
ResultValidator<T> |
whenTimeAdvancesTo(Instant newPointInTime)
Simulates the time advancing in the current given state using an
Instant as the unit of time. |
ResultValidator<T> |
whenTimeElapses(Duration elapsedTime)
Simulates the time elapsing in the current given state using a
Duration as the unit of time. |
FixtureConfiguration<T> |
withSubtypes(Class<? extends T>... subtypes)
Registers subtypes of this aggregate to support aggregate polymorphism.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
registerInjectableResources
andThenTimeAdvancesTo, andThenTimeElapses
@SafeVarargs public final FixtureConfiguration<T> withSubtypes(Class<? extends T>... subtypes)
FixtureConfiguration
withSubtypes
in interface FixtureConfiguration<T>
subtypes
- subtypes in this polymorphic hierarchypublic FixtureConfiguration<T> useStateStorage()
FixtureConfiguration
org.axonframework.commandhandling.model.Repository
with this fixture.
Should be used before calling FixtureConfiguration.givenState(Supplier)
or FixtureConfiguration.givenCommands(List)
(Supplier)}.useStateStorage
in interface FixtureConfiguration<T>
public FixtureConfiguration<T> registerRepository(Repository<T> repository)
FixtureConfiguration
repository
with the fixture. The repository must be wired
with the Event Store of this test fixture.
Should not be used in combination with FixtureConfiguration.registerAggregateFactory(org.axonframework.eventsourcing.AggregateFactory)
, as that will overwrite any
repository previously registered.registerRepository
in interface FixtureConfiguration<T>
repository
- The repository to use in the test casepublic FixtureConfiguration<T> registerRepositoryProvider(RepositoryProvider repositoryProvider)
FixtureConfiguration
registerRepositoryProvider
in interface FixtureConfiguration<T>
repositoryProvider
- provides repositories for specified aggregate typespublic FixtureConfiguration<T> registerAggregateFactory(AggregateFactory<T> aggregateFactory)
FixtureConfiguration
aggregateFactory
with the fixture. The repository used by the fixture will use
the given factory to create new aggregate instances. Defaults to an Aggregate Factory that uses the no-arg
constructor to create new instances.
Should not be used in combination with FixtureConfiguration.registerRepository(Repository)
, as that will overwrite any aggregate factory previously registered.registerAggregateFactory
in interface FixtureConfiguration<T>
aggregateFactory
- The Aggregate Factory to create empty aggregates withpublic FixtureConfiguration<T> registerAnnotatedCommandHandler(Object annotatedCommandHandler)
FixtureConfiguration
annotatedCommandHandler
with this fixture. This will register this command handler
with the command bus used in this fixture.registerAnnotatedCommandHandler
in interface FixtureConfiguration<T>
annotatedCommandHandler
- The command handler to register for this testpublic FixtureConfiguration<T> registerCommandHandler(Class<?> payloadType, MessageHandler<CommandMessage<?>> commandHandler)
FixtureConfiguration
commandHandler
to handle commands of the given commandType
with the
command bus used by this fixture.registerCommandHandler
in interface FixtureConfiguration<T>
payloadType
- The type of command to register the handler forcommandHandler
- The handler to registerpublic FixtureConfiguration<T> registerCommandHandler(String commandName, MessageHandler<CommandMessage<?>> commandHandler)
FixtureConfiguration
commandHandler
to handle commands of the given commandType
with the
command bus used by this fixture.registerCommandHandler
in interface FixtureConfiguration<T>
commandName
- The name of the command to register the handler forcommandHandler
- The handler to registerpublic FixtureConfiguration<T> registerInjectableResource(Object resource)
FixtureConfiguration
@CommandHandler
, @EventSourcingHandler
and EventHandler
.
These resource must be registered before registering any command handler.registerInjectableResource
in interface FixtureConfiguration<T>
resource
- the resource eligible for injectionpublic FixtureConfiguration<T> registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
FixtureConfiguration
ParameterResolverFactory
within this fixture. The given parameterResolverFactory
will be added to the other parameter resolver factories introduced through ClasspathParameterResolverFactory.forClass(Class)
and the SimpleResourceParameterResolverFactory
adding the registered resources
(with FixtureConfiguration.registerInjectableResource(Object)
. The generic T
is used as input for the ClasspathParameterResolverFactory#forClass(Class)
operation.registerParameterResolverFactory
in interface FixtureConfiguration<T>
parameterResolverFactory
- the ParameterResolver
to register within this fixtureFixtureConfiguration.registerInjectableResource(Object)
public FixtureConfiguration<T> registerCommandDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> commandDispatchInterceptor)
FixtureConfiguration
MessageDispatchInterceptor
for CommandMessage
s which will be invoked before any
command is dispatched on the CommandBus
to perform a task specified in the interceptor. For example by
adding MetaData
or throwing an exception based on the command.registerCommandDispatchInterceptor
in interface FixtureConfiguration<T>
commandDispatchInterceptor
- the MessageDispatchInterceptor
for CommandMessage
s to be added
to this fixture's CommandBus
public FixtureConfiguration<T> registerCommandHandlerInterceptor(MessageHandlerInterceptor<? super CommandMessage<?>> commandHandlerInterceptor)
FixtureConfiguration
MessageHandlerInterceptor
for CommandMessage
s which will be invoked before or after
the command has been dispatched on the CommandBus
to perform a task specified in the interceptor. It
could for example block the command for security reasons or add auditing to the command busregisterCommandHandlerInterceptor
in interface FixtureConfiguration<T>
commandHandlerInterceptor
- the MessageHandlerInterceptor
for CommandMessage
s to be added to
this fixture's CommandBus
public FixtureConfiguration<T> registerDeadlineDispatchInterceptor(MessageDispatchInterceptor<? super DeadlineMessage<?>> deadlineDispatchInterceptor)
FixtureConfiguration
DeadlineManager
to perform a task specified in the
interceptor.registerDeadlineDispatchInterceptor
in interface FixtureConfiguration<T>
deadlineDispatchInterceptor
- the interceptor for dispatching (scheduling) deadlinespublic FixtureConfiguration<T> registerDeadlineHandlerInterceptor(MessageHandlerInterceptor<? super DeadlineMessage<?>> deadlineHandlerInterceptor)
FixtureConfiguration
registerDeadlineHandlerInterceptor
in interface FixtureConfiguration<T>
deadlineHandlerInterceptor
- the interceptor for handling deadlinespublic FixtureConfiguration<T> registerFieldFilter(FieldFilter fieldFilter)
FixtureConfiguration
fieldFilter
, which is used to define which Fields are used when comparing objects.
The ResultValidator.expectEvents(Object...)
and ResultValidator.expectResultMessagePayload(Object)
,
for example, use this filter.
When multiple filters are registered, a Field must be accepted by all registered filters in order to be
accepted.
By default, all Fields are included in the comparison.registerFieldFilter
in interface FixtureConfiguration<T>
fieldFilter
- The FieldFilter that defines which fields to include in the comparisonpublic FixtureConfiguration<T> registerIgnoredField(Class<?> declaringClass, String fieldName)
FixtureConfiguration
fieldName
, which is declared in given declaringClass
is ignored when performing deep equality checks.registerIgnoredField
in interface FixtureConfiguration<T>
declaringClass
- The class declaring the fieldfieldName
- The name of the fieldpublic FixtureConfiguration<T> registerHandlerDefinition(HandlerDefinition handlerDefinition)
FixtureConfiguration
HandlerDefinition
within this fixture. The given handlerDefinition
is added to the
handler definitions introduced through ClasspathHandlerDefinition.forClass(Class)
.
The generic T
is used as input for the ClasspathHandlerDefinition#forClass(Class)
operation.registerHandlerDefinition
in interface FixtureConfiguration<T>
handlerDefinition
- used to create concrete handlerspublic FixtureConfiguration<T> registerHandlerEnhancerDefinition(HandlerEnhancerDefinition handlerEnhancerDefinition)
FixtureConfiguration
HandlerEnhancerDefinition
within this fixture. This given handlerEnhancerDefinition
is added to the handler enhancer definitions introduced through ClasspathHandlerEnhancerDefinition.forClass(Class)
.
The generic T
is used as input for the ClasspathHandlerEnhancerDefinition#forClass(Class)
operation.registerHandlerEnhancerDefinition
in interface FixtureConfiguration<T>
handlerEnhancerDefinition
- the HandlerEnhancerDefinition
to register within this fixturepublic FixtureConfiguration<T> registerCommandTargetResolver(CommandTargetResolver commandTargetResolver)
FixtureConfiguration
CommandTargetResolver
within this fixture. The commandTargetResolver
will replace
the default implementation (defined by the AggregateAnnotationCommandHandler
within this fixture.registerCommandTargetResolver
in interface FixtureConfiguration<T>
commandTargetResolver
- the CommandTargetResolver
used to resolve an Aggregate for a given commandpublic TestExecutor<T> given(Object... domainEvents)
FixtureConfiguration
domainEvents
as the "given" events. These are the events returned by the event store
when an aggregate is loaded.
If an item in the given domainEvents
implements Message
, the payload and MetaData
from
that Message
are copied into a newly created DomainEventMessage
.
Otherwise, a DomainEventMessage
with the item as payload and empty MetaData
is created.
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
given
in interface FixtureConfiguration<T>
domainEvents
- The domain events the event store should return.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> andGiven(Object... domainEvents)
TestExecutor
domainEvents
as the "given" events. These are the events returned by the event
store when an aggregate is loaded.
If an item in the given domainEvents
implements Message
, the
payload and meta-data from that message are copied into a newly created Domain Event Message. Otherwise, a
Domain Event Message with the item as payload and empty meta-data is created.andGiven
in interface TestExecutor<T>
domainEvents
- the domain events the event store should returnpublic TestExecutor<T> givenNoPriorActivity()
FixtureConfiguration
givenNoPriorActivity
in interface FixtureConfiguration<T>
TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> givenState(Supplier<T> aggregate)
FixtureConfiguration
aggregateState
as the initial state for a test case.
Usage of this method is highly discouraged for event sourced aggregates. In that case, use
FixtureConfiguration.given(Object...)
to specify historic events.
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
givenState
in interface FixtureConfiguration<T>
aggregate
- A Supplier
providing the state to use as starting point for this fixture.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> given(List<?> domainEvents)
FixtureConfiguration
domainEvents
as the "given" events. These are the events returned by the event store
when an aggregate is loaded.
If an item in the list implements Message
, the payload and MetaData
from that Message
are
copied into a newly created DomainEventMessage
. Otherwise, a
DomainEventMessage
with the item as payload and empty MetaData
is created.
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
given
in interface FixtureConfiguration<T>
domainEvents
- The domain events the event store should return.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> andGiven(List<?> domainEvents)
TestExecutor
domainEvents
as the "given" events. These are the events returned by the event
store when an aggregate is loaded.
If an item in the list implements Message
, the payload and meta-data from that
message are copied into a newly created Domain Event Message. Otherwise, a Domain Event Message with the item
as payload and empty meta-data is created.andGiven
in interface TestExecutor<T>
domainEvents
- the domain events the event store should returnpublic TestExecutor<T> givenCommands(Object... commands)
FixtureConfiguration
commands
as to execute against the aggregate under test to initiate the given-phase.
The commands are executed, and the resulting stored events are captured.
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
givenCommands
in interface FixtureConfiguration<T>
commands
- The commands to execute against the aggregate under test to initiate the given-phase.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> andGivenCommands(Object... commands)
TestExecutor
commands
as the command that will provide the "given" events. The commands are
executed, and the resulting stored events are captured.andGivenCommands
in interface TestExecutor<T>
commands
- the domain events the event store should returnpublic TestExecutor<T> givenCommands(List<?> commands)
FixtureConfiguration
commands
as to execute against the aggregate under test to initiate the given-phase.
The commands are executed, and the resulting stored events are captured.
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
givenCommands
in interface FixtureConfiguration<T>
commands
- The commands to execute against the aggregate under test to initiate the given-phase.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> andGivenCommands(List<?> commands)
TestExecutor
commands
as the command that will provide the "given" events. The commands are
executed, and the resulting stored events are captured.andGivenCommands
in interface TestExecutor<T>
commands
- the domain events the event store should returnpublic TestExecutor<T> givenCurrentTime(Instant currentTime)
FixtureConfiguration
Note that transitioning to the returned TestExecutor
will clear any previously defined "given" state to
ensure the fixture can run a clean test environment.
givenCurrentTime
in interface FixtureConfiguration<T>
currentTime
- An Instant
defining the simulated "current time" at which the given state is initialized.TestExecutor
instance that can execute the test with this configuration.public TestExecutor<T> andGivenCurrentTime(Instant currentTime)
TestExecutor
andGivenCurrentTime
in interface TestExecutor<T>
currentTime
- The simulated "current time" at which the given state is initializedpublic Instant currentTime()
TestExecutor
currentTime
in interface TestExecutor<T>
public ResultValidator<T> whenTimeElapses(Duration elapsedTime)
TestExecutor
Duration
as the unit of time. This can be
useful when the time between given events is of importance, for example when leveraging the
DeadlineManager
to schedule deadlines in the context of a given Aggregate.
Note: As this method is added to the interface as a replacement for the deprecated
TestExecutor.whenThenTimeAdvancesTo(Instant)
method, and in case there are other implementations by 3rd party
libraries, this method is changed to a default method that rely on the deprecated method so that there is no
breaking changes in the API in case an external implementation of this interface. Nevertheless, the recommended
approach is to override this implementation.
whenTimeElapses
in interface TestExecutor<T>
elapsedTime
- a Duration
specifying the amount of time that will elapseResultValidator
that can be used to validate the resulting actions of the command execution@Deprecated public ResultValidator<T> whenThenTimeElapses(Duration elapsedTime)
TestExecutor
Duration
as the unit of time. This can be
useful when the time between given events is of importance, for example when leveraging the
DeadlineManager
to schedule deadlines in the context of a given Aggregate.whenThenTimeElapses
in interface TestExecutor<T>
elapsedTime
- a Duration
specifying the amount of time that will elapseResultValidator
that can be used to validate the resulting actions of the command executionpublic ResultValidator<T> whenTimeAdvancesTo(Instant newPointInTime)
TestExecutor
Instant
as the unit of time. This can be
useful when the time between given events is of importance, for example when leveraging the
DeadlineManager
to schedule deadlines in the context of a given Aggregate.
Note: As this method is added to the interface as a replacement for the deprecated
TestExecutor.whenThenTimeAdvancesTo(Instant)
method, and in case there are other implementations by 3rd party
libraries, this method is changed to a default method that rely on the deprecated method so that there is no
breaking changes in the API in case an external implementation of this interface. Nevertheless, the recommended
approach is to override this implementation.
whenTimeAdvancesTo
in interface TestExecutor<T>
newPointInTime
- an Instant
specifying the amount of time to advance the clock toResultValidator
that can be used to validate the resulting actions of the command execution@Deprecated public ResultValidator<T> whenThenTimeAdvancesTo(Instant newPointInTime)
TestExecutor
Instant
as the unit of time. This can be
useful when the time between given events is of importance, for example when leveraging the
DeadlineManager
to schedule deadlines in the context of a given Aggregate.whenThenTimeAdvancesTo
in interface TestExecutor<T>
newPointInTime
- an Instant
specifying the amount of time to advance the clock toResultValidator
that can be used to validate the resulting actions of the command executionpublic ResultValidator<T> when(Object command)
TestExecutor
command
is a CommandMessage
instance, it will be dispatched as-is. Any other object will
cause the given command
to be wrapped in a CommandMessage
as its payload.when
in interface TestExecutor<T>
command
- The command to executepublic ResultValidator<T> when(Object command, Map<String,?> metaData)
TestExecutor
command
is a CommandMessage
instance, it will be dispatched as-is, with given
additional metaData
. Any other object will cause the given command
to be wrapped in a
CommandMessage
as its payload.when
in interface TestExecutor<T>
command
- The command to executemetaData
- The meta-data to attach to thepublic ResultValidator<T> whenConstructing(Callable<T> aggregateFactory)
TestExecutor
aggregateFactory
expecting an aggregate instance of type T
to be returned.
All activity is recorded in the fixture for result validation. The aggregateFactory
typically refers to
one of the aggregate's constructors.
You should use this when-phase operation whenever you do not use the
CommandHandler
annotation on the aggregate's methods, nor have
registered
an external command handler
invoking the Repository
.
whenConstructing
in interface TestExecutor<T>
aggregateFactory
- A callable operation expecting an aggregate instance of type T
to be returned.
This typically is an aggregate constructor invocation.ResultValidator
that can be used to validate the resulting actions of executing the given
aggregateFactory
.public ResultValidator<T> whenInvoking(String aggregateId, Consumer<T> aggregateSupplier)
TestExecutor
aggregateConsumer
after loading an aggregate of type T
based on the given
aggregateIdentifier
.
All activity is recorded in the fixture for result validation.
You should use this when-phase operation whenever you do not use the
CommandHandler
annotation on the aggregate's methods, nor have
registered
an external command handler
invoking the Repository
.
whenInvoking
in interface TestExecutor<T>
aggregateId
- The identifier of the aggregate to
Repository.load(String)
.aggregateSupplier
- A lambda providing an aggregate instance of type T
based on the given
aggregateIdentifier
.ResultValidator
that can be used to validate the resulting actions of executing the given
aggregateConsumer
.protected void handleDeadline(ScopeDescriptor aggregateDescriptor, DeadlineMessage<?> deadlineMessage) throws Exception
deadlineMessage
in the aggregate described by the given aggregateDescriptor
.
Deadline message is handled in the scope of a UnitOfWork
. If handling the deadline results in an
exception, the exception will be wrapped in a FixtureExecutionException
.aggregateDescriptor
- A ScopeDescriptor
describing the aggregate under testdeadlineMessage
- The DeadlineMessage
to be handledException
public void setReportIllegalStateChange(boolean reportIllegalStateChange)
FixtureConfiguration
setReportIllegalStateChange
in interface FixtureConfiguration<T>
reportIllegalStateChange
- whether or not to detect and report state changes outside of Event Handler
methods.public CommandBus getCommandBus()
FixtureConfiguration
getCommandBus
in interface FixtureConfiguration<T>
public EventBus getEventBus()
FixtureConfiguration
ResultValidator
operations.getEventBus
in interface FixtureConfiguration<T>
public EventStore getEventStore()
FixtureConfiguration
getEventStore
in interface FixtureConfiguration<T>
public Repository<T> getRepository()
FixtureConfiguration
getRepository
in interface FixtureConfiguration<T>
Copyright © 2010–2024. All rights reserved.