Class SnapshotTestKit
java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.SnapshotTestKit
Class for testing persisted snapshots in persistent actors.
-
Constructor Summary
ConstructorsConstructorDescriptionSnapshotTestKit(ActorSystem system) SnapshotTestKit(SnapshotTestKit scalaTestkit) -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Clear all data from storage.voidclearByPersistenceId(String persistenceId) Clear all data from storage for particular persistence id.static SnapshotTestKitcreate(ActorSystem system) static SnapshotTestKitcreate(ActorSystem<?> system) <A> AexpectNextPersisted(String persistenceId, A snapshot) Check thatsnapshothas been saved in the storage.<A> AexpectNextPersisted(String persistenceId, A snapshot, Duration max) Check formaxtime thatsnapshothas been saved in the storage.<A> AexpectNextPersistedClass(String persistenceId, Class<A> cla) Check that next persisted in storage for particular persistence id snapshot has expected type.<A> AexpectNextPersistedClass(String persistenceId, Class<A> cla, Duration max) Check formaxtime that next persisted in storage for particular persistence id snapshot has expected type.voidexpectNothingPersisted(String persistenceId) Check that nothing has been saved in the storage.voidexpectNothingPersisted(String persistenceId, Duration max) Check formaxtime that nothing has been saved in the storage.voidFail next delete from storage attempt with default exception for any persistence id.voidfailNextDelete(String persistenceId) Fail next delete from storage attempt with default exception for particular persistence id.voidfailNextDelete(String persistenceId, Throwable cause) Fail next delete from storage attempt withcauseexception for particular persistence id.voidfailNextDelete(Throwable cause) Fail next delete from storage attempt withcauseexception for any persistence id.voidfailNextNDeletes(int n) Fail next n delete from storage attempts with default exception for any persistence id.voidfailNextNDeletes(int n, Throwable cause) Fail next n delete from storage attempts withcauseexception for any persistence id.voidfailNextNDeletes(String persistenceId, int n) Fail next n delete from storage attempts with default exception for particular persistence id.voidfailNextNDeletes(String persistenceId, int n, Throwable cause) Fail next n delete from storage attempts withcauseexception for particular persistence id.voidfailNextNOps(int n) Fail n following journal operations regardless of their type.voidfailNextNOps(int n, Throwable cause) Failnfollowing journal operations depending on the conditioncond.voidfailNextNOpsCond(BiFunction<String, SnapshotOperation, Object> cond, int n) Failnfollowing journal operations depending on the conditioncond.voidfailNextNOpsCond(BiFunction<String, SnapshotOperation, Object> cond, int n, Throwable cause) Failnfollowing journal operations depending on the conditioncond.voidfailNextNPersisted(int n) Fail nextnwrite operations with default exception for any persistence id.voidfailNextNPersisted(int n, Throwable cause) Fail nextnwrite operations with thecauseexception for any persistence id.voidfailNextNPersisted(String persistenceId, int n) Fail nextnwrite operations for particular persistence id.voidfailNextNPersisted(String persistenceId, int n, Throwable cause) Fail nextnwrite operations with thecauseexception for particular persistence id.voidfailNextNReads(int n) Fail next n read from storage (recovery) attempts with default exception for any persistence id.voidfailNextNReads(int n, Throwable cause) Fail next n read from storage (recovery) attempts withcauseexception for any persistence id.voidfailNextNReads(String persistenceId, int n) Fail next n read from storage (recovery) attempts with default exception for particular persistence id.voidfailNextNReads(String persistenceId, int n, Throwable cause) Fail next n read from storage (recovery) attempts withcauseexception for particular persistence id.voidFail next write operations with default exception for any persistence id.voidfailNextPersisted(String persistenceId) Fail next write operations with default exception for particular persistence id.voidfailNextPersisted(String persistenceId, Throwable cause) Fail next write operations withcauseexception for particular persistence id.voidfailNextPersisted(Throwable cause) Fail next write operations withcauseexception for any persistence id.voidFail next read from storage (recovery) attempt with default exception for any persistence id.voidfailNextRead(String persistenceId) Fail next read from storage (recovery) attempt with default exception for any persistence id.voidfailNextRead(String persistenceId, Throwable cause) Fail next read from storage (recovery) attempt withcauseexception for particular persistence id.voidfailNextRead(Throwable cause) Fail next read from storage (recovery) attempt withcauseexception for any persistence id.persistedInStorage(String persistenceId) Retrieve all snapshots and their metadata saved in storage by persistence id.voidpersistForRecovery(String persistenceId, List<Pair<SnapshotMeta, Object>> snapshots) Persistsnapshotswith metadata into storage in order.<A> List<A>receivePersisted(String persistenceId, int n, Class<A> cla) Receive nextnsnapshots that have been persisted in the storage.<A> List<A>receivePersisted(String persistenceId, int n, Class<A> cla, Duration max) Receive formaxtime nextnsnapshots that have been persisted in the storage.voidReturns default policy if it was changed bywithPolicy(org.apache.pekko.persistence.testkit.ProcessingPolicy<org.apache.pekko.persistence.testkit.SnapshotOperation>).withPolicy(ProcessingPolicy<SnapshotOperation> policy) Set new processing policy for journal operations.
-
Constructor Details
-
SnapshotTestKit
-
SnapshotTestKit
-
-
Method Details
-
create
-
create
-
expectNothingPersisted
Check that nothing has been saved in the storage. -
expectNothingPersisted
Check formaxtime that nothing has been saved in the storage. -
expectNextPersisted
Check thatsnapshothas been saved in the storage. -
expectNextPersisted
Check formaxtime thatsnapshothas been saved in the storage. -
expectNextPersistedClass
Check that next persisted in storage for particular persistence id snapshot has expected type. -
expectNextPersistedClass
Check formaxtime that next persisted in storage for particular persistence id snapshot has expected type. -
failNextNPersisted
Fail nextnwrite operations with thecauseexception for particular persistence id. -
failNextNPersisted
Fail nextnwrite operations for particular persistence id. -
failNextNPersisted
Fail nextnwrite operations with thecauseexception for any persistence id. -
failNextNPersisted
public void failNextNPersisted(int n) Fail nextnwrite operations with default exception for any persistence id. -
failNextPersisted
Fail next write operations withcauseexception for particular persistence id. -
failNextPersisted
Fail next write operations with default exception for particular persistence id. -
failNextPersisted
Fail next write operations withcauseexception for any persistence id. -
failNextPersisted
public void failNextPersisted()Fail next write operations with default exception for any persistence id. -
failNextRead
Fail next read from storage (recovery) attempt withcauseexception for any persistence id. -
failNextRead
public void failNextRead()Fail next read from storage (recovery) attempt with default exception for any persistence id. -
failNextRead
Fail next read from storage (recovery) attempt withcauseexception for particular persistence id. -
failNextRead
Fail next read from storage (recovery) attempt with default exception for any persistence id. -
failNextNReads
Fail next n read from storage (recovery) attempts withcauseexception 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
Fail next n read from storage (recovery) attempts withcauseexception for particular persistence id. -
failNextNReads
Fail next n read from storage (recovery) attempts with default exception for particular persistence id. -
failNextDelete
Fail next delete from storage attempt withcauseexception for any persistence id. -
failNextDelete
public void failNextDelete()Fail next delete from storage attempt with default exception for any persistence id. -
failNextDelete
Fail next delete from storage attempt withcauseexception for particular persistence id. -
failNextDelete
Fail next delete from storage attempt with default exception for particular persistence id. -
failNextNDeletes
Fail next n delete from storage attempts withcauseexception 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
Fail next n delete from storage attempts withcauseexception for particular persistence id. -
failNextNDeletes
Fail next n delete from storage attempts with default exception for particular persistence id. -
receivePersisted
Receive nextnsnapshots that have been persisted in the storage. -
receivePersisted
Receive formaxtime nextnsnapshots that have been persisted in the storage. -
persistForRecovery
Persistsnapshotswith metadata into storage in order. -
persistedInStorage
Retrieve all snapshots and their metadata saved in storage by persistence id. -
clearAll
public void clearAll()Clear all data from storage. -
clearByPersistenceId
Clear all data from storage for particular persistence id. -
failNextNOpsCond
Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with defaultExpectedFailureexception. -
failNextNOpsCond
public void failNextNOpsCond(BiFunction<String, SnapshotOperation, Object> cond, int n, Throwable cause) Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with thecauseexception. -
failNextNOps
public void failNextNOps(int n) Fail n following journal operations regardless of their type. Fails operations with defaultExpectedFailureexception. -
failNextNOps
Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with thecauseexception. -
withPolicy
Set new processing policy for journal operations. NOTE! Overrides previously invokedfailNext...orrejectNext... -
resetPolicy
public void resetPolicy()Returns default policy if it was changed bywithPolicy(org.apache.pekko.persistence.testkit.ProcessingPolicy<org.apache.pekko.persistence.testkit.SnapshotOperation>).
-