Class SnapshotTestKit
- java.lang.Object
-
- akka.persistence.testkit.scaladsl.SnapshotTestKit
-
- All Implemented Interfaces:
ClearOps
,CommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
,ExpectOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>>
,HasStorage<SnapshotOperation,scala.Tuple2<SnapshotMetadata,java.lang.Object>>
,PolicyOpsTestKit<SnapshotOperation>
public class SnapshotTestKit extends java.lang.Object implements CommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>, PolicyOpsTestKit<SnapshotOperation>, ExpectOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>>, HasStorage<SnapshotOperation,scala.Tuple2<SnapshotMetadata,java.lang.Object>>
Class for testing snapshots of persistent actors.NOTE! ActorSystem must be configured with
PersistenceTestKitSnapshotPlugin
. The configuration can be retrieved withPersistenceTestKitSnapshotPlugin.config
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SnapshotTestKit.Settings
static class
SnapshotTestKit.Settings$
-
Constructor Summary
Constructors Constructor Description SnapshotTestKit(ActorSystem system)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SnapshotTestKit
apply(ActorSystem system)
static SnapshotTestKit
apply(ActorSystem<?> system)
<A> A
expectNextPersisted(java.lang.String persistenceId, A event)
Check thatevent
has been saved in the storage.void
failNextNDeletes(int n, java.lang.Throwable cause)
Fail next n delete from storage attempts withcause
exception for any persistence id.void
failNextNDeletes(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail next n delete from storage attempts withcause
exception for particular persistence id.void
failNextNPersisted(int n, java.lang.Throwable cause)
Fail nextn
write operations with thecause
exception for any persistence id.void
failNextNPersisted(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail nextn
write operations with thecause
exception for particular persistence id.void
failNextNReads(int n, java.lang.Throwable cause)
Fail next n read from storage (recovery) attempts withcause
exception for any persistence id.void
failNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail next n read from storage (recovery) attempts withcause
exception for particular persistence id.scala.Option<java.lang.Object>
getItem(java.lang.String persistenceId, int nextInd)
scala.collection.immutable.Seq<scala.Tuple2<SnapshotMeta,java.lang.Object>>
persistedInStorage(java.lang.String persistenceId)
Retrieve snapshots and their metadata from storage by persistence id.void
persistForRecovery(java.lang.String persistenceId, scala.collection.immutable.Seq<scala.Tuple2<SnapshotMeta,java.lang.Object>> elems)
Persistelems
pairs of (snapshot metadata, snapshot payload) into storage.void
persistForRecovery(java.lang.String persistenceId, scala.Tuple2<SnapshotMeta,java.lang.Object> elem)
Persist a pair of (snapshot metadata, snapshot payload) into storage.protected SnapshotStorage
storage()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.persistence.testkit.scaladsl.ClearOps
clearAll, clearByPersistenceId
-
Methods inherited from interface akka.persistence.testkit.scaladsl.CommonTestKitOps
expectNextPersisted, expectNothingPersisted, expectNothingPersisted, failNextDelete, failNextDelete, failNextDelete, failNextDelete, failNextNDeletes, failNextNDeletes, failNextNPersisted, failNextNPersisted, failNextNReads, failNextNReads, failNextPersisted, failNextPersisted, failNextPersisted, failNextPersisted, failNextRead, failNextRead, failNextRead, failNextRead
-
Methods inherited from interface akka.persistence.testkit.scaladsl.ExpectOps
expectNextPersisted, expectNextPersistedClass, expectNextPersistedClass, expectNextPersistedType, expectNextPersistedType, expectNothingPersisted, expectNothingPersisted, receivePersisted, receivePersisted, receivePersisted, receivePersisted
-
Methods inherited from interface akka.persistence.testkit.scaladsl.HasStorage
addToIndex, clearIndexStorage, nextIndex, nextIndexByPersistenceId_$eq, removeLastIndex, setIndex
-
Methods inherited from interface akka.persistence.testkit.scaladsl.PolicyOpsTestKit
failNextNOps, failNextNOps, failNextNOpsCond, failNextNOpsCond, resetPolicy, withPolicy
-
-
-
-
Constructor Detail
-
SnapshotTestKit
public SnapshotTestKit(ActorSystem system)
-
-
Method Detail
-
apply
public static SnapshotTestKit apply(ActorSystem system)
-
apply
public static SnapshotTestKit apply(ActorSystem<?> system)
-
storage
protected SnapshotStorage storage()
- Specified by:
storage
in interfaceHasStorage<SnapshotOperation,scala.Tuple2<SnapshotMetadata,java.lang.Object>>
-
getItem
public scala.Option<java.lang.Object> getItem(java.lang.String persistenceId, int nextInd)
- Specified by:
getItem
in interfaceExpectOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>>
-
expectNextPersisted
public <A> A expectNextPersisted(java.lang.String persistenceId, A event)
Description copied from interface:CommonTestKitOps
Check thatevent
has been saved in the storage.- Specified by:
expectNextPersisted
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
- Specified by:
expectNextPersisted
in interfaceExpectOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>>
-
failNextNPersisted
public void failNextNPersisted(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail nextn
write operations with thecause
exception for particular persistence id.- Specified by:
failNextNPersisted
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
failNextNPersisted
public void failNextNPersisted(int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail nextn
write operations with thecause
exception for any persistence id.- Specified by:
failNextNPersisted
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
failNextNReads
public void failNextNReads(int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail next n read from storage (recovery) attempts withcause
exception for any persistence id.- Specified by:
failNextNReads
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
failNextNReads
public void failNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail next n read from storage (recovery) attempts withcause
exception for particular persistence id.- Specified by:
failNextNReads
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
failNextNDeletes
public void failNextNDeletes(int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail next n delete from storage attempts withcause
exception for any persistence id.- Specified by:
failNextNDeletes
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
failNextNDeletes
public void failNextNDeletes(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Description copied from interface:CommonTestKitOps
Fail next n delete from storage attempts withcause
exception for particular persistence id.- Specified by:
failNextNDeletes
in interfaceCommonTestKitOps<scala.Tuple2<SnapshotMetadata,java.lang.Object>,SnapshotOperation>
-
persistForRecovery
public void persistForRecovery(java.lang.String persistenceId, scala.collection.immutable.Seq<scala.Tuple2<SnapshotMeta,java.lang.Object>> elems)
Persistelems
pairs of (snapshot metadata, snapshot payload) into storage.
-
persistForRecovery
public void persistForRecovery(java.lang.String persistenceId, scala.Tuple2<SnapshotMeta,java.lang.Object> elem)
Persist a pair of (snapshot metadata, snapshot payload) into storage.
-
persistedInStorage
public scala.collection.immutable.Seq<scala.Tuple2<SnapshotMeta,java.lang.Object>> persistedInStorage(java.lang.String persistenceId)
Retrieve snapshots and their metadata from storage by persistence id.
-
-