public class PersistentEntityTestDriver<C,E,S> extends Object
PersistentEntity
emits expected events and side-effects in response to incoming commands.
It also verifies that all commands, events, replies and state are
serializable, and reports any such problems in the issues
of the Outcome
.
Constructor and Description |
---|
PersistentEntityTestDriver(akka.actor.ActorSystem system,
PersistentEntity<C,E,S> entity,
String entityId) |
Modifier and Type | Method and Description |
---|---|
List<PersistentEntityTestDriver.Issue> |
getAllIssues()
Accumulated issues from all previous runs.
|
PersistentEntityTestDriver.Outcome<E,S> |
initialize(Optional<S> snapshotState,
Object... events)
Initialize the entity.
|
PersistentEntityTestDriver.Outcome<E,S> |
initialize(Optional<S> snapshotState,
scala.collection.Seq<E> events)
Initialize the entity.
|
PersistentEntityTestDriver.Outcome<E,S> |
run(Object... commands)
The entity will process the commands and the emitted events and side effects
are recorded and provided in the returned
Outcome . |
PersistentEntityTestDriver.Outcome<E,S> |
run(scala.collection.Seq<C> commands)
The entity will process the commands and the emitted events and side effects
are recorded and provided in the returned
Outcome . |
public PersistentEntityTestDriver(akka.actor.ActorSystem system, PersistentEntity<C,E,S> entity, String entityId)
public PersistentEntityTestDriver.Outcome<E,S> initialize(Optional<S> snapshotState, Object... events)
This can be used to simulate the startup of an entity, be passing some snapshot state, and then some additional events that weren't included in that entity.
The returned outcome contains the state with events applied to it and any issues with the state and events.
This method may not be invoked twice, and it also must not be invoked after passing commands to the run
method,
since that will automatically initialize the entity with an empty snapshot if not yet initialized.
snapshotState
- The state to initialize the entity with.events
- The additional events to run before invoking recoveryCompleted
public PersistentEntityTestDriver.Outcome<E,S> run(Object... commands)
Outcome
. Current state is also
included in the Outcome
.
run
may be invoked multiple times to divide the sequence of commands
into manageable steps. The Outcome
contains the events and side-effects of
the last run
, but the state is not reset between different runs.
public PersistentEntityTestDriver.Outcome<E,S> initialize(Optional<S> snapshotState, scala.collection.Seq<E> events)
This can be used to simulate the startup of an entity, be passing some snapshot state, and then some additional events that weren't included in that entity.
The returned outcome contains the state with events applied to it and any issues with the state and events.
This method may not be invoked twice, and it also must not be invoked after passing commands to the run
method,
since that will automatically initialize the entity with an empty snapshot if not yet initialized.
snapshotState
- The state to initialize the entity with.events
- The additional events to run before invoking recoveryCompleted
public PersistentEntityTestDriver.Outcome<E,S> run(scala.collection.Seq<C> commands)
Outcome
. Current state is also
included in the Outcome
.
run
may be invoked multiple times to divide the sequence of commands
into manageable steps. The Outcome
contains the events and side-effects of
the last run
, but the state is not reset between different runs.
public List<PersistentEntityTestDriver.Issue> getAllIssues()