Class EventSourcedBehaviorTestKit<Command,Event,State>
java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.EventSourcedBehaviorTestKit<Command,Event,State>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe result of running a command.static final classThe result of running a command with aActorRef, i.e.replyTo static final classThe result of restarting the behavior.static final classCustomization of which serialization checks that are performed. -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the in-memory journal and snapshot storage and restarts the behavior.static com.typesafe.config.Configconfig()The configuration to be included in the configuration of theActorSystem.static <Command,Event, State>
EventSourcedBehaviorTestKit<Command,Event, State> create(ActorSystem<?> system, Behavior<Command> behavior) Factory method to create a new EventSourcedBehaviorTestKit.static <Command,Event, State>
EventSourcedBehaviorTestKit<Command,Event, State> create(ActorSystem<?> system, Behavior<Command> behavior, EventSourcedBehaviorTestKit.SerializationSettings serializationSettings) Factory method to create a new EventSourcedBehaviorTestKit with customEventSourcedBehaviorTestKit.SerializationSettings.getState()Retrieve the current state of the Behavior.voidinitialize(Object... events) voidinitialize(scala.collection.immutable.Seq<Event> events) voidinitialize(State state, Object... events) Initializes behavior from provided state and/or events.voidinitialize(State state, scala.collection.immutable.Seq<Event> events) Initializes behavior from provided state and/or events.The underlyingPersistenceTestKitfor the in-memory journal.restart()Restart the behavior, which will then recover from stored snapshot and events.runCommand(Command command) Run one command through the behavior.runCommand(Function<ActorRef<R>, Command> creator) Run one command with areplyTo: ActorRefthrough the behavior.The underlyingSnapshotTestKitfor snapshot storage.
-
Constructor Details
-
EventSourcedBehaviorTestKit
-
-
Method Details
-
config
public static com.typesafe.config.Config config()The configuration to be included in the configuration of theActorSystem. Typically used as constructor parameter toTestKitJunitResource. The configuration enables the in-memory journal and snapshot storage. -
enabledSerializationSettings
-
disabledSerializationSettings
-
create
public static <Command,Event, EventSourcedBehaviorTestKit<Command,State> Event, createState> (ActorSystem<?> system, Behavior<Command> behavior) Factory method to create a new EventSourcedBehaviorTestKit. -
create
public static <Command,Event, EventSourcedBehaviorTestKit<Command,State> Event, createState> (ActorSystem<?> system, Behavior<Command> behavior, EventSourcedBehaviorTestKit.SerializationSettings serializationSettings) Factory method to create a new EventSourcedBehaviorTestKit with customEventSourcedBehaviorTestKit.SerializationSettings.Note that
equalsmust be implemented in the commands, events and state ifverifyEqualityis enabled. -
initialize
Initializes behavior from provided state and/or events. -
initialize
-
runCommand
Run one command through the behavior. The returned result contains emitted events and the state after applying the events. -
runCommand
public <R> EventSourcedBehaviorTestKit.CommandResultWithReply<Command,Event, runCommandState, R> (Function<ActorRef<R>, Command> creator) Run one command with areplyTo: ActorRefthrough the behavior. The returned result contains emitted events, the state after applying the events, and the reply. -
getState
Retrieve the current state of the Behavior. -
restart
Restart the behavior, which will then recover from stored snapshot and events. Can be used for testing that the recovery is correct. -
clear
public void clear()Clears the in-memory journal and snapshot storage and restarts the behavior. -
initialize
Initializes behavior from provided state and/or events. -
initialize
-
persistenceTestKit
The underlyingPersistenceTestKitfor the in-memory journal. Can be useful for advanced testing scenarios, such as simulating failures or populating the journal with events that are used for replay. -
snapshotTestKit
The underlyingSnapshotTestKitfor snapshot storage. Present only if snapshots are enabled. Can be useful for advanced testing scenarios, such as simulating failures or populating the storage with snapshots that are used for replay.
-