Class EventSourcedBehaviorTestKit<Command,Event,State>

java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.EventSourcedBehaviorTestKit<Command,Event,State>

public final class EventSourcedBehaviorTestKit<Command,Event,State> extends Object
  • Constructor Details

  • Method Details

    • config

      public static com.typesafe.config.Config config()
      The configuration to be included in the configuration of the ActorSystem. Typically used as constructor parameter to TestKitJunitResource. 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 custom EventSourcedBehaviorTestKit.SerializationSettings.

      Note that equals must be implemented in the commands, events and state if verifyEquality is enabled.

    • initialize

      public void initialize(State state, Object... events)
      Initializes behavior from provided state and/or events.
    • initialize

      public void initialize(Object... events)
    • runCommand

      Run one command through the behavior. The returned result contains emitted events and the state after applying the events.
    • runCommand

      Run one command with a replyTo: 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

      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

      public void initialize(State state, scala.collection.immutable.Seq<Event> events)
      Initializes behavior from provided state and/or events.
    • initialize

      public void initialize(scala.collection.immutable.Seq<Event> events)
    • persistenceTestKit

      public PersistenceTestKit persistenceTestKit()
      The underlying PersistenceTestKit for 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

      public Optional<SnapshotTestKit> snapshotTestKit()
      The underlying SnapshotTestKit for 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.