Class PersistenceTestKit
java.lang.Object
org.apache.pekko.persistence.testkit.javadsl.PersistenceTestKit
Class for testing persisted events in persistent actors.
-
Constructor Summary
ConstructorsConstructorDescriptionPersistenceTestKit(ActorSystem system) PersistenceTestKit(PersistenceTestKit scalaTestkit) -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Clear all data from storage.voidClear all data in storage preserving sequence numbers.voidclearByIdPreservingSeqNumbers(String persistenceId) Clear all data in storage for particular persistence id preserving sequence numbers.voidclearByPersistenceId(String persistenceId) Clear all data from storage for particular persistence id.static PersistenceTestKitcreate(ActorSystem system) static PersistenceTestKitcreate(ActorSystem<?> system) <A> AexpectNextPersisted(String persistenceId, A event) Check thateventhas been saved in the storage.<A> AexpectNextPersisted(String persistenceId, A event, Duration max) Check formaxtime thateventhas been saved in the storage.<A> AexpectNextPersistedClass(String persistenceId, Class<A> cla) Check that next persisted in storage for particular persistence id event has expected type.<A> AexpectNextPersistedClass(String persistenceId, Class<A> cla, Duration max) Check formaxtime that next persisted in storage for particular persistence id event 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, JournalOperation, Object> cond, int n) Failnfollowing journal operations depending on the conditioncond.voidfailNextNOpsCond(BiFunction<String, JournalOperation, 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 operation with default exception for any persistence id.voidfailNextPersisted(String persistenceId) Fail next write operation with default exception for particular persistence id.voidfailNextPersisted(String persistenceId, Throwable cause) Fail next write operation withcauseexception for particular persistence id.voidfailNextPersisted(Throwable cause) Fail next write operation event 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 events saved in storage by persistence id.voidpersistForRecovery(String persistenceId, List<Object> events) Persisteventsinto storage in order.<A> List<A>receivePersisted(String persistenceId, int n, Class<A> cla) Receive next n events from the storage.<A> List<A>receivePersisted(String persistenceId, int n, Class<A> cla, Duration max) Receive formaxtime next n events from the storage.voidReject next delete from storage operation for any persistence id with default exception.voidrejectNextDelete(String persistenceId) Reject next delete from storage operations for particular persistence id with default exception.voidrejectNextDelete(String persistenceId, Throwable cause) Reject next delete from storage operations for particular persistence id withcauseexception.voidrejectNextDelete(Throwable cause) Reject next delete from storage operation for any persistence id withcauseexception.voidrejectNextNDeletes(int n) Reject next n delete from storage operations for any persistence id with default exception.voidrejectNextNDeletes(int n, Throwable cause) Reject next n delete from storage operations for any persistence id withcauseexception.voidrejectNextNDeletes(String persistenceId, int n) Reject next n delete from storage operations for particular persistence id with default exception.voidrejectNextNDeletes(String persistenceId, int n, Throwable cause) Reject next n delete from storage operations for particular persistence id withcauseexception.voidrejectNextNOps(int n) Reject n following journal operations regardless of their type.voidrejectNextNOps(int n, Throwable cause) Rejectnfollowing journal operations regardless of their type.voidrejectNextNOpsCond(BiFunction<String, JournalOperation, Object> cond, int n) Rejectnfollowing journal operations depending on the conditioncond.voidrejectNextNOpsCond(BiFunction<String, JournalOperation, Object> cond, int n, Throwable cause) Rejectnfollowing journal operations depending on the conditioncond.voidrejectNextNPersisted(int n) Reject next n save in storage operations for any persistence id with default exception.voidrejectNextNPersisted(int n, Throwable cause) Reject next n save in storage operations for any persistence id withcauseexception.voidrejectNextNPersisted(String persistenceId, int n) Reject next n save in storage operations for particular persistence id with default exception.voidrejectNextNPersisted(String persistenceId, int n, Throwable cause) Reject next n save in storage operations for particular persistence id withcauseexception.voidrejectNextNReads(int n) Reject next n read from storage operations for any persistence id with default exception.voidrejectNextNReads(int n, Throwable cause) Reject next n read from storage operations for any persistence id withcauseexception.voidrejectNextNReads(String persistenceId, int n) Reject next n read from storage operations for particular persistence id with default exception.voidrejectNextNReads(String persistenceId, int n, Throwable cause) Reject next n read from storage operations for particular persistence id withcauseexception.voidReject next save in storage operation for any persistence id with default exception.voidrejectNextPersisted(String persistenceId) Reject next save in storage operation for particular persistence id with default exception.voidrejectNextPersisted(String persistenceId, Throwable cause) Reject next save in storage operation for particular persistence id withcauseexception.voidrejectNextPersisted(Throwable cause) Reject next save in storage operation for any persistence id withcauseexception.voidReject next read from storage operation for any persistence id with default exception.voidrejectNextRead(String persistenceId) Reject next read from storage operation for particular persistence id with default exception.voidrejectNextRead(String persistenceId, Throwable cause) Reject next read from storage operation for particular persistence id withcauseexception.voidrejectNextRead(Throwable cause) Reject next read from storage operation for any persistence id withcauseexception.voidReturns default policy if it was changed bywithPolicy(org.apache.pekko.persistence.testkit.ProcessingPolicy<org.apache.pekko.persistence.testkit.JournalOperation>).withPolicy(ProcessingPolicy<JournalOperation> policy) Set new processing policy for journal operations.
-
Constructor Details
-
PersistenceTestKit
-
PersistenceTestKit
-
-
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 thateventhas been saved in the storage. -
expectNextPersisted
Check formaxtime thateventhas been saved in the storage. -
expectNextPersistedClass
Check that next persisted in storage for particular persistence id event has expected type. -
expectNextPersistedClass
Check formaxtime that next persisted in storage for particular persistence id event 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 operation withcauseexception for particular persistence id. -
failNextPersisted
Fail next write operation with default exception for particular persistence id. -
failNextPersisted
Fail next write operation event withcauseexception for any persistence id. -
failNextPersisted
public void failNextPersisted()Fail next write operation 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 next n events from the storage. -
receivePersisted
Receive formaxtime next n events from the storage. -
rejectNextNPersisted
Reject next n save in storage operations for particular persistence id withcauseexception. -
rejectNextNPersisted
Reject next n save in storage operations for particular persistence id with default exception. -
rejectNextNPersisted
public void rejectNextNPersisted(int n) Reject next n save in storage operations for any persistence id with default exception. -
rejectNextNPersisted
Reject next n save in storage operations for any persistence id withcauseexception. -
rejectNextPersisted
Reject next save in storage operation for particular persistence id with default exception. -
rejectNextPersisted
Reject next save in storage operation for particular persistence id withcauseexception. -
rejectNextPersisted
Reject next save in storage operation for any persistence id withcauseexception. -
rejectNextPersisted
public void rejectNextPersisted()Reject next save in storage operation for any persistence id with default exception. -
rejectNextRead
public void rejectNextRead()Reject next read from storage operation for any persistence id with default exception. -
rejectNextRead
Reject next read from storage operation for any persistence id withcauseexception. -
rejectNextNReads
public void rejectNextNReads(int n) Reject next n read from storage operations for any persistence id with default exception. -
rejectNextNReads
Reject next n read from storage operations for any persistence id withcauseexception. -
rejectNextRead
Reject next read from storage operation for particular persistence id with default exception. -
rejectNextRead
Reject next read from storage operation for particular persistence id withcauseexception. -
rejectNextNReads
Reject next n read from storage operations for particular persistence id with default exception. -
rejectNextNReads
Reject next n read from storage operations for particular persistence id withcauseexception. -
rejectNextDelete
public void rejectNextDelete()Reject next delete from storage operation for any persistence id with default exception. -
rejectNextDelete
Reject next delete from storage operation for any persistence id withcauseexception. -
rejectNextNDeletes
public void rejectNextNDeletes(int n) Reject next n delete from storage operations for any persistence id with default exception. -
rejectNextNDeletes
Reject next n delete from storage operations for any persistence id withcauseexception. -
rejectNextDelete
Reject next delete from storage operations for particular persistence id with default exception. -
rejectNextDelete
Reject next delete from storage operations for particular persistence id withcauseexception. -
rejectNextNDeletes
Reject next n delete from storage operations for particular persistence id with default exception. -
rejectNextNDeletes
Reject next n delete from storage operations for particular persistence id withcauseexception. -
rejectNextNOpsCond
Rejectnfollowing journal operations depending on the conditioncond. Rejection triggers, whencondreturns true. Reject operations with defaultExpectedRejectionexception. -
rejectNextNOpsCond
public void rejectNextNOpsCond(BiFunction<String, JournalOperation, Object> cond, int n, Throwable cause) Rejectnfollowing journal operations depending on the conditioncond. Rejection triggers, whencondreturns true. Rejects operations with thecauseexception. -
rejectNextNOps
public void rejectNextNOps(int n) Reject n following journal operations regardless of their type. Rejects operations with defaultExpectedRejectionexception. -
rejectNextNOps
Rejectnfollowing journal operations regardless of their type. Rejects operations with thecauseexception. -
persistForRecovery
Persisteventsinto storage in order. -
persistedInStorage
Retrieve all events saved in storage by persistence id. -
clearAll
public void clearAll()Clear all data from storage.NOTE! Also clears sequence numbers in storage!
- See Also:
-
clearByPersistenceId
Clear all data from storage for particular persistence id.NOTE! Also clears sequence number in storage!
-
clearAllPreservingSeqNumbers
public void clearAllPreservingSeqNumbers()Clear all data in storage preserving sequence numbers.- See Also:
-
clearByIdPreservingSeqNumbers
Clear all data in storage for particular persistence id preserving sequence numbers.- See Also:
-
failNextNOpsCond
Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with defaultExpectedFailureexception. -
failNextNOpsCond
public void failNextNOpsCond(BiFunction<String, JournalOperation, 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.JournalOperation>).
-