Package akka.persistence.testkit.javadsl
Class EventSourcedBehaviorTestKit<Command,Event,State>
- java.lang.Object
-
- akka.persistence.testkit.javadsl.EventSourcedBehaviorTestKit<Command,Event,State>
-
public final class EventSourcedBehaviorTestKit<Command,Event,State> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventSourcedBehaviorTestKit.CommandResult<Command,Event,State>
The result of running a command.static class
EventSourcedBehaviorTestKit.CommandResultWithReply<Command,Event,State,Reply>
The result of running a command with aActorRef
, i.e.replyTo static class
EventSourcedBehaviorTestKit.RestartResult<State>
The result of restarting the behavior.static class
EventSourcedBehaviorTestKit.SerializationSettings
Customization of which serialization checks that are performed.
-
Constructor Summary
Constructors Constructor Description EventSourcedBehaviorTestKit(EventSourcedBehaviorTestKit<Command,Event,State> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the in-memory journal and snapshot storage and restarts the behavior.static com.typesafe.config.Config
config()
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
.static EventSourcedBehaviorTestKit.SerializationSettings
disabledSerializationSettings()
static EventSourcedBehaviorTestKit.SerializationSettings
enabledSerializationSettings()
State
getState()
Retrieve the current state of the Behavior.PersistenceTestKit
persistenceTestKit()
The underlyingPersistenceTestKit
for the in-memory journal and snapshot storage.EventSourcedBehaviorTestKit.RestartResult<State>
restart()
Restart the behavior, which will then recover from stored snapshot and events.EventSourcedBehaviorTestKit.CommandResult<Command,Event,State>
runCommand(Command command)
Run one command through the behavior.<R> EventSourcedBehaviorTestKit.CommandResultWithReply<Command,Event,State,R>
runCommand(java.util.function.Function<ActorRef<R>,Command> creator)
Run one command with areplyTo: ActorRef
through the behavior.
-
-
-
Constructor Detail
-
EventSourcedBehaviorTestKit
public EventSourcedBehaviorTestKit(EventSourcedBehaviorTestKit<Command,Event,State> delegate)
-
-
Method Detail
-
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
public static EventSourcedBehaviorTestKit.SerializationSettings enabledSerializationSettings()
-
disabledSerializationSettings
public static EventSourcedBehaviorTestKit.SerializationSettings disabledSerializationSettings()
-
create
public static <Command,Event,State> EventSourcedBehaviorTestKit<Command,Event,State> create(ActorSystem<?> system, Behavior<Command> behavior)
Factory method to create a new EventSourcedBehaviorTestKit.
-
create
public 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
.Note that
equals
must be implemented in the commands, events and state ifverifyEquality
is enabled.
-
runCommand
public EventSourcedBehaviorTestKit.CommandResult<Command,Event,State> runCommand(Command command)
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,State,R> runCommand(java.util.function.Function<ActorRef<R>,Command> creator)
Run one command with areplyTo: ActorRef
through the behavior. The returned result contains emitted events, the state after applying the events, and the reply.
-
getState
public State getState()
Retrieve the current state of the Behavior.
-
restart
public EventSourcedBehaviorTestKit.RestartResult<State> 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.
-
persistenceTestKit
public PersistenceTestKit persistenceTestKit()
The underlyingPersistenceTestKit
for the in-memory journal and snapshot storage. Can be useful for advanced testing scenarios, such as simulating failures or populating the journal with events that are used for replay.
-
-