Class DurableStateBehaviorTestKit<Command,State>
java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.DurableStateBehaviorTestKit<Command,State>
- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe result of running a command.static final classThe result of running a command with anActorRef, 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()Clear the state for this behavior from the in-memory durable state store and restart the behavior.static com.typesafe.config.Configconfig()The configuration to be included in the configuration of theActorSystem.static <Command,State>
DurableStateBehaviorTestKit<Command,State> create(ActorSystem<?> system, Behavior<Command> behavior) Factory method to create a new DurableStateBehaviorTestKit.static <Command,State>
DurableStateBehaviorTestKit<Command,State> create(ActorSystem<?> system, Behavior<Command> behavior, DurableStateBehaviorTestKit.SerializationSettings serializationSettings) Factory method to create a new DurableStateBehaviorTestKit with customDurableStateBehaviorTestKit.SerializationSettings.getState()Retrieve the current state of the behavior.restart()Restart the behavior, which will then recover from the durable state store.runCommand(Command command) Run one command through the behavior.runCommand(Function<ActorRef<R>, Command> creator) Run one command with areplyTo: ActorRefthrough the behavior.
-
Constructor Details
-
DurableStateBehaviorTestKit
-
-
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 durable state store. -
enabledSerializationSettings
-
disabledSerializationSettings
-
create
public static <Command,State> DurableStateBehaviorTestKit<Command,State> create(ActorSystem<?> system, Behavior<Command> behavior) Factory method to create a new DurableStateBehaviorTestKit. -
create
public static <Command,State> DurableStateBehaviorTestKit<Command,State> create(ActorSystem<?> system, Behavior<Command> behavior, DurableStateBehaviorTestKit.SerializationSettings serializationSettings) Factory method to create a new DurableStateBehaviorTestKit with customDurableStateBehaviorTestKit.SerializationSettings.Note that
equalsmust be implemented in the commands and state ifverifyEqualityis enabled. -
runCommand
Run one command through the behavior. The returned result contains the state after the command has been processed. -
runCommand
public <R> DurableStateBehaviorTestKit.CommandResultWithReply<Command,State, runCommandR> (Function<ActorRef<R>, Command> creator) Run one command with areplyTo: ActorRefthrough the behavior. The returned result contains the state after the command has been processed, and the reply. -
getState
Retrieve the current state of the behavior. -
restart
Restart the behavior, which will then recover from the durable state store. Can be used for testing that the recovery is correct. -
clear
public void clear()Clear the state for this behavior from the in-memory durable state store and restart the behavior.
-