Class SnapshotTestKit

java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.SnapshotTestKit

public class SnapshotTestKit extends Object
Class for testing persisted snapshots in persistent actors.
  • Constructor Details

    • SnapshotTestKit

      public SnapshotTestKit(SnapshotTestKit scalaTestkit)
    • SnapshotTestKit

      public SnapshotTestKit(ActorSystem system)
  • Method Details

    • create

      public static SnapshotTestKit create(ActorSystem system)
    • create

      public static SnapshotTestKit create(ActorSystem<?> system)
    • expectNothingPersisted

      public void expectNothingPersisted(String persistenceId)
      Check that nothing has been saved in the storage.
    • expectNothingPersisted

      public void expectNothingPersisted(String persistenceId, Duration max)
      Check for max time that nothing has been saved in the storage.
    • expectNextPersisted

      public <A> A expectNextPersisted(String persistenceId, A snapshot)
      Check that snapshot has been saved in the storage.
    • expectNextPersisted

      public <A> A expectNextPersisted(String persistenceId, A snapshot, Duration max)
      Check for max time that snapshot has been saved in the storage.
    • expectNextPersistedClass

      public <A> A expectNextPersistedClass(String persistenceId, Class<A> cla)
      Check that next persisted in storage for particular persistence id snapshot has expected type.
    • expectNextPersistedClass

      public <A> A expectNextPersistedClass(String persistenceId, Class<A> cla, Duration max)
      Check for max time that next persisted in storage for particular persistence id snapshot has expected type.
    • failNextNPersisted

      public void failNextNPersisted(String persistenceId, int n, Throwable cause)
      Fail next n write operations with the cause exception for particular persistence id.
    • failNextNPersisted

      public void failNextNPersisted(String persistenceId, int n)
      Fail next n write operations for particular persistence id.
    • failNextNPersisted

      public void failNextNPersisted(int n, Throwable cause)
      Fail next n write operations with the cause exception for any persistence id.
    • failNextNPersisted

      public void failNextNPersisted(int n)
      Fail next n write operations with default exception for any persistence id.
    • failNextPersisted

      public void failNextPersisted(String persistenceId, Throwable cause)
      Fail next write operations with cause exception for particular persistence id.
    • failNextPersisted

      public void failNextPersisted(String persistenceId)
      Fail next write operations with default exception for particular persistence id.
    • failNextPersisted

      public void failNextPersisted(Throwable cause)
      Fail next write operations with cause exception for any persistence id.
    • failNextPersisted

      public void failNextPersisted()
      Fail next write operations with default exception for any persistence id.
    • failNextRead

      public void failNextRead(Throwable cause)
      Fail next read from storage (recovery) attempt with cause exception for any persistence id.
    • failNextRead

      public void failNextRead()
      Fail next read from storage (recovery) attempt with default exception for any persistence id.
    • failNextRead

      public void failNextRead(String persistenceId, Throwable cause)
      Fail next read from storage (recovery) attempt with cause exception for particular persistence id.
    • failNextRead

      public void failNextRead(String persistenceId)
      Fail next read from storage (recovery) attempt with default exception for any persistence id.
    • failNextNReads

      public void failNextNReads(int n, Throwable cause)
      Fail next n read from storage (recovery) attempts with cause exception for any persistence id.
    • failNextNReads

      public void failNextNReads(int n)
      Fail next n read from storage (recovery) attempts with default exception for any persistence id.
    • failNextNReads

      public void failNextNReads(String persistenceId, int n, Throwable cause)
      Fail next n read from storage (recovery) attempts with cause exception for particular persistence id.
    • failNextNReads

      public void failNextNReads(String persistenceId, int n)
      Fail next n read from storage (recovery) attempts with default exception for particular persistence id.
    • failNextDelete

      public void failNextDelete(Throwable cause)
      Fail next delete from storage attempt with cause exception for any persistence id.
    • failNextDelete

      public void failNextDelete()
      Fail next delete from storage attempt with default exception for any persistence id.
    • failNextDelete

      public void failNextDelete(String persistenceId, Throwable cause)
      Fail next delete from storage attempt with cause exception for particular persistence id.
    • failNextDelete

      public void failNextDelete(String persistenceId)
      Fail next delete from storage attempt with default exception for particular persistence id.
    • failNextNDeletes

      public void failNextNDeletes(int n, Throwable cause)
      Fail next n delete from storage attempts with cause exception for any persistence id.
    • failNextNDeletes

      public void failNextNDeletes(int n)
      Fail next n delete from storage attempts with default exception for any persistence id.
    • failNextNDeletes

      public void failNextNDeletes(String persistenceId, int n, Throwable cause)
      Fail next n delete from storage attempts with cause exception for particular persistence id.
    • failNextNDeletes

      public void failNextNDeletes(String persistenceId, int n)
      Fail next n delete from storage attempts with default exception for particular persistence id.
    • receivePersisted

      public <A> List<A> receivePersisted(String persistenceId, int n, Class<A> cla)
      Receive next n snapshots that have been persisted in the storage.
    • receivePersisted

      public <A> List<A> receivePersisted(String persistenceId, int n, Class<A> cla, Duration max)
      Receive for max time next n snapshots that have been persisted in the storage.
    • persistForRecovery

      public void persistForRecovery(String persistenceId, List<Pair<SnapshotMeta,Object>> snapshots)
      Persist snapshots with metadata into storage in order.
    • persistedInStorage

      public List<Pair<SnapshotMeta,Object>> persistedInStorage(String persistenceId)
      Retrieve all snapshots and their metadata saved in storage by persistence id.
    • clearAll

      public void clearAll()
      Clear all data from storage.
    • clearByPersistenceId

      public void clearByPersistenceId(String persistenceId)
      Clear all data from storage for particular persistence id.
    • failNextNOpsCond

      public void failNextNOpsCond(BiFunction<String,SnapshotOperation,Object> cond, int n)
      Fail n following journal operations depending on the condition cond. Failure triggers, when cond returns true. Fails operations with default ExpectedFailure exception.
    • failNextNOpsCond

      public void failNextNOpsCond(BiFunction<String,SnapshotOperation,Object> cond, int n, Throwable cause)
      Fail n following journal operations depending on the condition cond. Failure triggers, when cond returns true. Fails operations with the cause exception.
    • failNextNOps

      public void failNextNOps(int n)
      Fail n following journal operations regardless of their type. Fails operations with default ExpectedFailure exception.
    • failNextNOps

      public void failNextNOps(int n, Throwable cause)
      Fail n following journal operations depending on the condition cond. Failure triggers, when cond returns true. Fails operations with the cause exception.
    • withPolicy

      public SnapshotTestKit withPolicy(ProcessingPolicy<SnapshotOperation> policy)
      Set new processing policy for journal operations. NOTE! Overrides previously invoked failNext... or rejectNext...
    • resetPolicy

      public void resetPolicy()