Package org.axonframework.test.aggregate
Class StubAggregateLifecycle
java.lang.Object
org.axonframework.messaging.Scope
org.axonframework.modelling.command.AggregateLifecycle
org.axonframework.test.aggregate.StubAggregateLifecycle
- Direct Known Subclasses:
StubAggregateLifecycleExtension,StubAggregateLifecycleRule
public class StubAggregateLifecycle
extends org.axonframework.modelling.command.AggregateLifecycle
Stub implementation of an AggregateLifecycle that registers all applied events for verification later. This
lifecycle instance can be activated (see
activate()) and deactivated (see close()) at will. Events
applied while it is active are stored and can be retrieved using getAppliedEvents() or
getAppliedEventPayloads().
When using with JUnit, consider using the StubAggregateLifecycleRule with @Rule
instead, as it is easier and safer to use.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates this lifecycle instance.voidclose()Closes this lifecycle instance, restoring to the situation prior to this lifecycle being started.protected <T> org.axonframework.modelling.command.ApplyMoredoApply(T payload, org.axonframework.messaging.MetaData metaData) protected <T> org.axonframework.modelling.command.Aggregate<T>doCreateNew(Class<T> aggregateType, Callable<T> factoryMethod) protected voidReturns the payloads of the Events applied while this lifecycle instance was active.List<org.axonframework.eventhandling.EventMessage<?>>Returns the list of applied Events for this lifecycle instance.protected booleanprotected ObjectbooleanIndicates whether an Aggregate has invoked "markDeleted" while this lifecycle was active.protected Stringtype()protected Longversion()Methods inherited from class org.axonframework.modelling.command.AggregateLifecycle
apply, apply, createNew, describeScope, execute, getInstance, getVersion, isLive, markDeletedMethods inherited from class org.axonframework.messaging.Scope
describeCurrentScope, endScope, executeWithResult, getCurrentScope, startScope
-
Constructor Details
-
StubAggregateLifecycle
public StubAggregateLifecycle()
-
-
Method Details
-
activate
public void activate()Activates this lifecycle instance. Any invocations to static AggregateLifecycle methods will use this instance untilclose()is called. -
close
public void close()Closes this lifecycle instance, restoring to the situation prior to this lifecycle being started. If any lifecycle instance was active before this one started, it will be reactivated. -
getIsLive
protected boolean getIsLive()- Specified by:
getIsLivein classorg.axonframework.modelling.command.AggregateLifecycle
-
doCreateNew
protected <T> org.axonframework.modelling.command.Aggregate<T> doCreateNew(Class<T> aggregateType, Callable<T> factoryMethod) throws Exception - Specified by:
doCreateNewin classorg.axonframework.modelling.command.AggregateLifecycle- Throws:
Exception
-
type
- Specified by:
typein classorg.axonframework.modelling.command.AggregateLifecycle
-
identifier
- Specified by:
identifierin classorg.axonframework.modelling.command.AggregateLifecycle
-
version
- Specified by:
versionin classorg.axonframework.modelling.command.AggregateLifecycle
-
doMarkDeleted
protected void doMarkDeleted()- Specified by:
doMarkDeletedin classorg.axonframework.modelling.command.AggregateLifecycle
-
doApply
protected <T> org.axonframework.modelling.command.ApplyMore doApply(T payload, org.axonframework.messaging.MetaData metaData) - Specified by:
doApplyin classorg.axonframework.modelling.command.AggregateLifecycle
-
getAppliedEvents
Returns the list of applied Events for this lifecycle instance.Note that this list is not reset when activating or deactivating the lifecycle.
- Returns:
- the list of messages applied while this lifecycle instance was active
-
getAppliedEventPayloads
Returns the payloads of the Events applied while this lifecycle instance was active. This is usually the parameter passed to theAggregateLifecycle.apply(Object)method.- Returns:
- the payloads of the applied events.
-
isMarkedDeleted
public boolean isMarkedDeleted()Indicates whether an Aggregate has invoked "markDeleted" while this lifecycle was active.- Returns:
trueifAggregateLifecycle.markDeleted()was invoked, otherwisefalse
-