Class PersistenceTestKit
- java.lang.Object
- 
- org.apache.pekko.persistence.testkit.javadsl.PersistenceTestKit
 
- 
 public class PersistenceTestKit extends java.lang.ObjectClass for testing persisted events in persistent actors.
- 
- 
Constructor SummaryConstructors Constructor Description PersistenceTestKit(ActorSystem system)PersistenceTestKit(PersistenceTestKit scalaTestkit)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAll()Clear all data from storage.voidclearAllPreservingSeqNumbers()Clear all data in storage preserving sequence numbers.voidclearByIdPreservingSeqNumbers(java.lang.String persistenceId)Clear all data in storage for particular persistence id preserving sequence numbers.voidclearByPersistenceId(java.lang.String persistenceId)Clear all data from storage for particular persistence id.static PersistenceTestKitcreate(ActorSystem system)static PersistenceTestKitcreate(ActorSystem<?> system)<A> AexpectNextPersisted(java.lang.String persistenceId, A event)Check thateventhas been saved in the storage.<A> AexpectNextPersisted(java.lang.String persistenceId, A event, java.time.Duration max)Check formaxtime thateventhas been saved in the storage.<A> AexpectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla)Check that next persisted in storage for particular persistence id event has expected type.<A> AexpectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla, java.time.Duration max)Check formaxtime that next persisted in storage for particular persistence id event has expected type.voidexpectNothingPersisted(java.lang.String persistenceId)Check that nothing has been saved in the storage.voidexpectNothingPersisted(java.lang.String persistenceId, java.time.Duration max)Check formaxtime that nothing has been saved in the storage.voidfailNextDelete()Fail next delete from storage attempt with default exception for any persistence id.voidfailNextDelete(java.lang.String persistenceId)Fail next delete from storage attempt with default exception for particular persistence id.voidfailNextDelete(java.lang.String persistenceId, java.lang.Throwable cause)Fail next delete from storage attempt withcauseexception for particular persistence id.voidfailNextDelete(java.lang.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, java.lang.Throwable cause)Fail next n delete from storage attempts withcauseexception for any persistence id.voidfailNextNDeletes(java.lang.String persistenceId, int n)Fail next n delete from storage attempts with default exception for particular persistence id.voidfailNextNDeletes(java.lang.String persistenceId, int n, java.lang.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, java.lang.Throwable cause)Failnfollowing journal operations depending on the conditioncond.voidfailNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n)Failnfollowing journal operations depending on the conditioncond.voidfailNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n, java.lang.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, java.lang.Throwable cause)Fail nextnwrite operations with thecauseexception for any persistence id.voidfailNextNPersisted(java.lang.String persistenceId, int n)Fail nextnwrite operations for particular persistence id.voidfailNextNPersisted(java.lang.String persistenceId, int n, java.lang.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, java.lang.Throwable cause)Fail next n read from storage (recovery) attempts withcauseexception for any persistence id.voidfailNextNReads(java.lang.String persistenceId, int n)Fail next n read from storage (recovery) attempts with default exception for particular persistence id.voidfailNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)Fail next n read from storage (recovery) attempts withcauseexception for particular persistence id.voidfailNextPersisted()Fail next write operation with default exception for any persistence id.voidfailNextPersisted(java.lang.String persistenceId)Fail next write operation with default exception for particular persistence id.voidfailNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)Fail next write operation withcauseexception for particular persistence id.voidfailNextPersisted(java.lang.Throwable cause)Fail next write operation event withcauseexception for any persistence id.voidfailNextRead()Fail next read from storage (recovery) attempt with default exception for any persistence id.voidfailNextRead(java.lang.String persistenceId)Fail next read from storage (recovery) attempt with default exception for any persistence id.voidfailNextRead(java.lang.String persistenceId, java.lang.Throwable cause)Fail next read from storage (recovery) attempt withcauseexception for particular persistence id.voidfailNextRead(java.lang.Throwable cause)Fail next read from storage (recovery) attempt withcauseexception for any persistence id.java.util.List<java.lang.Object>persistedInStorage(java.lang.String persistenceId)Retrieve all events saved in storage by persistence id.voidpersistForRecovery(java.lang.String persistenceId, java.util.List<java.lang.Object> events)Persisteventsinto storage in order.<A> java.util.List<A>receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla)Receive next n events from the storage.<A> java.util.List<A>receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla, java.time.Duration max)Receive formaxtime next n events from the storage.voidrejectNextDelete()Reject next delete from storage operation for any persistence id with default exception.voidrejectNextDelete(java.lang.String persistenceId)Reject next delete from storage operations for particular persistence id with default exception.voidrejectNextDelete(java.lang.String persistenceId, java.lang.Throwable cause)Reject next delete from storage operations for particular persistence id withcauseexception.voidrejectNextDelete(java.lang.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, java.lang.Throwable cause)Reject next n delete from storage operations for any persistence id withcauseexception.voidrejectNextNDeletes(java.lang.String persistenceId, int n)Reject next n delete from storage operations for particular persistence id with default exception.voidrejectNextNDeletes(java.lang.String persistenceId, int n, java.lang.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, java.lang.Throwable cause)Rejectnfollowing journal operations regardless of their type.voidrejectNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n)Rejectnfollowing journal operations depending on the conditioncond.voidrejectNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n, java.lang.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, java.lang.Throwable cause)Reject next n save in storage operations for any persistence id withcauseexception.voidrejectNextNPersisted(java.lang.String persistenceId, int n)Reject next n save in storage operations for particular persistence id with default exception.voidrejectNextNPersisted(java.lang.String persistenceId, int n, java.lang.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, java.lang.Throwable cause)Reject next n read from storage operations for any persistence id withcauseexception.voidrejectNextNReads(java.lang.String persistenceId, int n)Reject next n read from storage operations for particular persistence id with default exception.voidrejectNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)Reject next n read from storage operations for particular persistence id withcauseexception.voidrejectNextPersisted()Reject next save in storage operation for any persistence id with default exception.voidrejectNextPersisted(java.lang.String persistenceId)Reject next save in storage operation for particular persistence id with default exception.voidrejectNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)Reject next save in storage operation for particular persistence id withcauseexception.voidrejectNextPersisted(java.lang.Throwable cause)Reject next save in storage operation for any persistence id withcauseexception.voidrejectNextRead()Reject next read from storage operation for any persistence id with default exception.voidrejectNextRead(java.lang.String persistenceId)Reject next read from storage operation for particular persistence id with default exception.voidrejectNextRead(java.lang.String persistenceId, java.lang.Throwable cause)Reject next read from storage operation for particular persistence id withcauseexception.voidrejectNextRead(java.lang.Throwable cause)Reject next read from storage operation for any persistence id withcauseexception.voidresetPolicy()Returns default policy if it was changed bywithPolicy(org.apache.pekko.persistence.testkit.ProcessingPolicy<org.apache.pekko.persistence.testkit.JournalOperation>).PersistenceTestKitwithPolicy(ProcessingPolicy<JournalOperation> policy)Set new processing policy for journal operations.
 
- 
- 
- 
Constructor Detail- 
PersistenceTestKitpublic PersistenceTestKit(PersistenceTestKit scalaTestkit) 
 - 
PersistenceTestKitpublic PersistenceTestKit(ActorSystem system) 
 
- 
 - 
Method Detail- 
createpublic static PersistenceTestKit create(ActorSystem system) 
 - 
createpublic static PersistenceTestKit create(ActorSystem<?> system) 
 - 
expectNothingPersistedpublic void expectNothingPersisted(java.lang.String persistenceId) Check that nothing has been saved in the storage.
 - 
expectNothingPersistedpublic void expectNothingPersisted(java.lang.String persistenceId, java.time.Duration max)Check formaxtime that nothing has been saved in the storage.
 - 
expectNextPersistedpublic <A> A expectNextPersisted(java.lang.String persistenceId, A event)Check thateventhas been saved in the storage.
 - 
expectNextPersistedpublic <A> A expectNextPersisted(java.lang.String persistenceId, A event, java.time.Duration max)Check formaxtime thateventhas been saved in the storage.
 - 
expectNextPersistedClasspublic <A> A expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla)Check that next persisted in storage for particular persistence id event has expected type.
 - 
expectNextPersistedClasspublic <A> A expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla, java.time.Duration max)Check formaxtime that next persisted in storage for particular persistence id event has expected type.
 - 
failNextNPersistedpublic void failNextNPersisted(java.lang.String persistenceId, int n, java.lang.Throwable cause)Fail nextnwrite operations with thecauseexception for particular persistence id.
 - 
failNextNPersistedpublic void failNextNPersisted(java.lang.String persistenceId, int n)Fail nextnwrite operations for particular persistence id.
 - 
failNextNPersistedpublic void failNextNPersisted(int n, java.lang.Throwable cause)Fail nextnwrite operations with thecauseexception for any persistence id.
 - 
failNextNPersistedpublic void failNextNPersisted(int n) Fail nextnwrite operations with default exception for any persistence id.
 - 
failNextPersistedpublic void failNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)Fail next write operation withcauseexception for particular persistence id.
 - 
failNextPersistedpublic void failNextPersisted(java.lang.String persistenceId) Fail next write operation with default exception for particular persistence id.
 - 
failNextPersistedpublic void failNextPersisted(java.lang.Throwable cause) Fail next write operation event withcauseexception for any persistence id.
 - 
failNextPersistedpublic void failNextPersisted() Fail next write operation with default exception for any persistence id.
 - 
failNextReadpublic void failNextRead(java.lang.Throwable cause) Fail next read from storage (recovery) attempt withcauseexception for any persistence id.
 - 
failNextReadpublic void failNextRead() Fail next read from storage (recovery) attempt with default exception for any persistence id.
 - 
failNextReadpublic void failNextRead(java.lang.String persistenceId, java.lang.Throwable cause)Fail next read from storage (recovery) attempt withcauseexception for particular persistence id.
 - 
failNextReadpublic void failNextRead(java.lang.String persistenceId) Fail next read from storage (recovery) attempt with default exception for any persistence id.
 - 
failNextNReadspublic void failNextNReads(int n, java.lang.Throwable cause)Fail next n read from storage (recovery) attempts withcauseexception for any persistence id.
 - 
failNextNReadspublic void failNextNReads(int n) Fail next n read from storage (recovery) attempts with default exception for any persistence id.
 - 
failNextNReadspublic void failNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)Fail next n read from storage (recovery) attempts withcauseexception for particular persistence id.
 - 
failNextNReadspublic void failNextNReads(java.lang.String persistenceId, int n)Fail next n read from storage (recovery) attempts with default exception for particular persistence id.
 - 
failNextDeletepublic void failNextDelete(java.lang.Throwable cause) Fail next delete from storage attempt withcauseexception for any persistence id.
 - 
failNextDeletepublic void failNextDelete() Fail next delete from storage attempt with default exception for any persistence id.
 - 
failNextDeletepublic void failNextDelete(java.lang.String persistenceId, java.lang.Throwable cause)Fail next delete from storage attempt withcauseexception for particular persistence id.
 - 
failNextDeletepublic void failNextDelete(java.lang.String persistenceId) Fail next delete from storage attempt with default exception for particular persistence id.
 - 
failNextNDeletespublic void failNextNDeletes(int n, java.lang.Throwable cause)Fail next n delete from storage attempts withcauseexception for any persistence id.
 - 
failNextNDeletespublic void failNextNDeletes(int n) Fail next n delete from storage attempts with default exception for any persistence id.
 - 
failNextNDeletespublic void failNextNDeletes(java.lang.String persistenceId, int n, java.lang.Throwable cause)Fail next n delete from storage attempts withcauseexception for particular persistence id.
 - 
failNextNDeletespublic void failNextNDeletes(java.lang.String persistenceId, int n)Fail next n delete from storage attempts with default exception for particular persistence id.
 - 
receivePersistedpublic <A> java.util.List<A> receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla)Receive next n events from the storage.
 - 
receivePersistedpublic <A> java.util.List<A> receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla, java.time.Duration max)Receive formaxtime next n events from the storage.
 - 
rejectNextNPersistedpublic void rejectNextNPersisted(java.lang.String persistenceId, int n, java.lang.Throwable cause)Reject next n save in storage operations for particular persistence id withcauseexception.
 - 
rejectNextNPersistedpublic void rejectNextNPersisted(java.lang.String persistenceId, int n)Reject next n save in storage operations for particular persistence id with default exception.
 - 
rejectNextNPersistedpublic void rejectNextNPersisted(int n) Reject next n save in storage operations for any persistence id with default exception.
 - 
rejectNextNPersistedpublic void rejectNextNPersisted(int n, java.lang.Throwable cause)Reject next n save in storage operations for any persistence id withcauseexception.
 - 
rejectNextPersistedpublic void rejectNextPersisted(java.lang.String persistenceId) Reject next save in storage operation for particular persistence id with default exception.
 - 
rejectNextPersistedpublic void rejectNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)Reject next save in storage operation for particular persistence id withcauseexception.
 - 
rejectNextPersistedpublic void rejectNextPersisted(java.lang.Throwable cause) Reject next save in storage operation for any persistence id withcauseexception.
 - 
rejectNextPersistedpublic void rejectNextPersisted() Reject next save in storage operation for any persistence id with default exception.
 - 
rejectNextReadpublic void rejectNextRead() Reject next read from storage operation for any persistence id with default exception.
 - 
rejectNextReadpublic void rejectNextRead(java.lang.Throwable cause) Reject next read from storage operation for any persistence id withcauseexception.
 - 
rejectNextNReadspublic void rejectNextNReads(int n) Reject next n read from storage operations for any persistence id with default exception.
 - 
rejectNextNReadspublic void rejectNextNReads(int n, java.lang.Throwable cause)Reject next n read from storage operations for any persistence id withcauseexception.
 - 
rejectNextReadpublic void rejectNextRead(java.lang.String persistenceId) Reject next read from storage operation for particular persistence id with default exception.
 - 
rejectNextReadpublic void rejectNextRead(java.lang.String persistenceId, java.lang.Throwable cause)Reject next read from storage operation for particular persistence id withcauseexception.
 - 
rejectNextNReadspublic void rejectNextNReads(java.lang.String persistenceId, int n)Reject next n read from storage operations for particular persistence id with default exception.
 - 
rejectNextNReadspublic void rejectNextNReads(java.lang.String persistenceId, int n, java.lang.Throwable cause)Reject next n read from storage operations for particular persistence id withcauseexception.
 - 
rejectNextDeletepublic void rejectNextDelete() Reject next delete from storage operation for any persistence id with default exception.
 - 
rejectNextDeletepublic void rejectNextDelete(java.lang.Throwable cause) Reject next delete from storage operation for any persistence id withcauseexception.
 - 
rejectNextNDeletespublic void rejectNextNDeletes(int n) Reject next n delete from storage operations for any persistence id with default exception.
 - 
rejectNextNDeletespublic void rejectNextNDeletes(int n, java.lang.Throwable cause)Reject next n delete from storage operations for any persistence id withcauseexception.
 - 
rejectNextDeletepublic void rejectNextDelete(java.lang.String persistenceId) Reject next delete from storage operations for particular persistence id with default exception.
 - 
rejectNextDeletepublic void rejectNextDelete(java.lang.String persistenceId, java.lang.Throwable cause)Reject next delete from storage operations for particular persistence id withcauseexception.
 - 
rejectNextNDeletespublic void rejectNextNDeletes(java.lang.String persistenceId, int n)Reject next n delete from storage operations for particular persistence id with default exception.
 - 
rejectNextNDeletespublic void rejectNextNDeletes(java.lang.String persistenceId, int n, java.lang.Throwable cause)Reject next n delete from storage operations for particular persistence id withcauseexception.
 - 
rejectNextNOpsCondpublic void rejectNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n) Rejectnfollowing journal operations depending on the conditioncond. Rejection triggers, whencondreturns true. Reject operations with defaultExpectedRejectionexception.
 - 
rejectNextNOpsCondpublic void rejectNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n, java.lang.Throwable cause) Rejectnfollowing journal operations depending on the conditioncond. Rejection triggers, whencondreturns true. Rejects operations with thecauseexception.
 - 
rejectNextNOpspublic void rejectNextNOps(int n) Reject n following journal operations regardless of their type. Rejects operations with defaultExpectedRejectionexception.
 - 
rejectNextNOpspublic void rejectNextNOps(int n, java.lang.Throwable cause)Rejectnfollowing journal operations regardless of their type. Rejects operations with thecauseexception.
 - 
persistForRecoverypublic void persistForRecovery(java.lang.String persistenceId, java.util.List<java.lang.Object> events)Persisteventsinto storage in order.
 - 
persistedInStoragepublic java.util.List<java.lang.Object> persistedInStorage(java.lang.String persistenceId) Retrieve all events saved in storage by persistence id.
 - 
clearAllpublic void clearAll() Clear all data from storage.NOTE! Also clears sequence numbers in storage! - See Also:
- clearAllPreservingSeqNumbers()
 
 - 
clearByPersistenceIdpublic void clearByPersistenceId(java.lang.String persistenceId) Clear all data from storage for particular persistence id.NOTE! Also clears sequence number in storage! 
 - 
clearAllPreservingSeqNumberspublic void clearAllPreservingSeqNumbers() Clear all data in storage preserving sequence numbers.- See Also:
- clearAll()
 
 - 
clearByIdPreservingSeqNumberspublic void clearByIdPreservingSeqNumbers(java.lang.String persistenceId) Clear all data in storage for particular persistence id preserving sequence numbers.- See Also:
- clearByPersistenceId(java.lang.String)
 
 - 
failNextNOpsCondpublic void failNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n) Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with defaultExpectedFailureexception.
 - 
failNextNOpsCondpublic void failNextNOpsCond(java.util.function.BiFunction<java.lang.String,JournalOperation,java.lang.Object> cond, int n, java.lang.Throwable cause) Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with thecauseexception.
 - 
failNextNOpspublic void failNextNOps(int n) Fail n following journal operations regardless of their type. Fails operations with defaultExpectedFailureexception.
 - 
failNextNOpspublic void failNextNOps(int n, java.lang.Throwable cause)Failnfollowing journal operations depending on the conditioncond. Failure triggers, whencondreturns true. Fails operations with thecauseexception.
 - 
withPolicypublic PersistenceTestKit withPolicy(ProcessingPolicy<JournalOperation> policy) Set new processing policy for journal operations. NOTE! Overrides previously invokedfailNext...orrejectNext...
 - 
resetPolicypublic void resetPolicy() Returns default policy if it was changed bywithPolicy(org.apache.pekko.persistence.testkit.ProcessingPolicy<org.apache.pekko.persistence.testkit.JournalOperation>).
 
- 
 
-