Package akka.persistence.testkit.javadsl
Class SnapshotTestKit
- java.lang.Object
-
- akka.persistence.testkit.javadsl.SnapshotTestKit
-
public class SnapshotTestKit extends java.lang.Object
Class for testing persisted snapshots in persistent actors.
-
-
Constructor Summary
Constructors Constructor Description SnapshotTestKit(ActorSystem system)
SnapshotTestKit(SnapshotTestKit scalaTestkit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAll()
Clear all data from storage.void
clearByPersistenceId(java.lang.String persistenceId)
Clear all data from storage for particular persistence id.static SnapshotTestKit
create(ActorSystem system)
static SnapshotTestKit
create(ActorSystem<?> system)
<A> A
expectNextPersisted(java.lang.String persistenceId, A snapshot)
Check thatsnapshot
has been saved in the storage.<A> A
expectNextPersisted(java.lang.String persistenceId, A snapshot, java.time.Duration max)
Check formax
time thatsnapshot
has been saved in the storage.<A> A
expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla)
Check that next persisted in storage for particular persistence id snapshot has expected type.<A> A
expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla, java.time.Duration max)
Check formax
time that next persisted in storage for particular persistence id snapshot has expected type.void
expectNothingPersisted(java.lang.String persistenceId)
Check that nothing has been saved in the storage.void
expectNothingPersisted(java.lang.String persistenceId, java.time.Duration max)
Check formax
time that nothing has been saved in the storage.void
failNextDelete()
Fail next delete from storage attempt with default exception for any persistence id.void
failNextDelete(java.lang.String persistenceId)
Fail next delete from storage attempt with default exception for particular persistence id.void
failNextDelete(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next delete from storage attempt withcause
exception for particular persistence id.void
failNextDelete(java.lang.Throwable cause)
Fail next delete from storage attempt withcause
exception for any persistence id.void
failNextNDeletes(int n)
Fail next n delete from storage attempts with default exception for any persistence id.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)
Fail next n delete from storage attempts with default exception for particular 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
failNextNOps(int n)
Fail n following journal operations regardless of their type.void
failNextNOps(int n, java.lang.Throwable cause)
Failn
following journal operations depending on the conditioncond
.void
failNextNOpsCond(java.util.function.BiFunction<java.lang.String,SnapshotOperation,java.lang.Object> cond, int n)
Failn
following journal operations depending on the conditioncond
.void
failNextNOpsCond(java.util.function.BiFunction<java.lang.String,SnapshotOperation,java.lang.Object> cond, int n, java.lang.Throwable cause)
Failn
following journal operations depending on the conditioncond
.void
failNextNPersisted(int n)
Fail nextn
write operations with default exception for any 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)
Fail nextn
write operations for particular 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)
Fail next n read from storage (recovery) attempts with default exception for any 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)
Fail next n read from storage (recovery) attempts with default exception for particular 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.void
failNextPersisted()
Fail next write operations with default exception for any persistence id.void
failNextPersisted(java.lang.String persistenceId)
Fail next write operations with default exception for particular persistence id.void
failNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next write operations withcause
exception for particular persistence id.void
failNextPersisted(java.lang.Throwable cause)
Fail next write operations withcause
exception for any persistence id.void
failNextRead()
Fail next read from storage (recovery) attempt with default exception for any persistence id.void
failNextRead(java.lang.String persistenceId)
Fail next read from storage (recovery) attempt with default exception for any persistence id.void
failNextRead(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next read from storage (recovery) attempt withcause
exception for particular persistence id.void
failNextRead(java.lang.Throwable cause)
Fail next read from storage (recovery) attempt withcause
exception for any persistence id.java.util.List<Pair<SnapshotMeta,java.lang.Object>>
persistedInStorage(java.lang.String persistenceId)
Retrieve all snapshots and their metadata saved in storage by persistence id.void
persistForRecovery(java.lang.String persistenceId, java.util.List<Pair<SnapshotMeta,java.lang.Object>> snapshots)
Persistsnapshots
with metadata into storage in order.<A> java.util.List<A>
receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla)
Receive nextn
snapshots that have been persisted in the storage.<A> java.util.List<A>
receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla, java.time.Duration max)
Receive formax
time nextn
snapshots that have been persisted in the storage.void
resetPolicy()
Returns default policy if it was changed by {@link SnapshotTestKit.withPolicy()}.SnapshotTestKit
withPolicy(ProcessingPolicy<SnapshotOperation> policy)
Set new processing policy for journal operations.
-
-
-
Constructor Detail
-
SnapshotTestKit
public SnapshotTestKit(SnapshotTestKit scalaTestkit)
-
SnapshotTestKit
public SnapshotTestKit(ActorSystem system)
-
-
Method Detail
-
create
public static SnapshotTestKit create(ActorSystem system)
-
create
public static SnapshotTestKit create(ActorSystem<?> system)
-
expectNothingPersisted
public void expectNothingPersisted(java.lang.String persistenceId)
Check that nothing has been saved in the storage.
-
expectNothingPersisted
public void expectNothingPersisted(java.lang.String persistenceId, java.time.Duration max)
Check formax
time that nothing has been saved in the storage.
-
expectNextPersisted
public <A> A expectNextPersisted(java.lang.String persistenceId, A snapshot)
Check thatsnapshot
has been saved in the storage.
-
expectNextPersisted
public <A> A expectNextPersisted(java.lang.String persistenceId, A snapshot, java.time.Duration max)
Check formax
time thatsnapshot
has been saved in the storage.
-
expectNextPersistedClass
public <A> A expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla)
Check that next persisted in storage for particular persistence id snapshot has expected type.
-
expectNextPersistedClass
public <A> A expectNextPersistedClass(java.lang.String persistenceId, java.lang.Class<A> cla, java.time.Duration max)
Check formax
time that next persisted in storage for particular persistence id snapshot has expected type.
-
failNextNPersisted
public void failNextNPersisted(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail nextn
write operations with thecause
exception for particular persistence id.
-
failNextNPersisted
public void failNextNPersisted(java.lang.String persistenceId, int n)
Fail nextn
write operations for particular persistence id.
-
failNextNPersisted
public void failNextNPersisted(int n, java.lang.Throwable cause)
Fail nextn
write operations with thecause
exception for any persistence id.
-
failNextNPersisted
public void failNextNPersisted(int n)
Fail nextn
write operations with default exception for any persistence id.
-
failNextPersisted
public void failNextPersisted(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next write operations withcause
exception for particular persistence id.
-
failNextPersisted
public void failNextPersisted(java.lang.String persistenceId)
Fail next write operations with default exception for particular persistence id.
-
failNextPersisted
public void failNextPersisted(java.lang.Throwable cause)
Fail next write operations withcause
exception for any persistence id.
-
failNextPersisted
public void failNextPersisted()
Fail next write operations with default exception for any persistence id.
-
failNextRead
public void failNextRead(java.lang.Throwable cause)
Fail next read from storage (recovery) attempt withcause
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(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next read from storage (recovery) attempt withcause
exception for particular persistence id.
-
failNextRead
public void failNextRead(java.lang.String persistenceId)
Fail next read from storage (recovery) attempt with default exception for any persistence id.
-
failNextNReads
public void failNextNReads(int n, java.lang.Throwable cause)
Fail next n read from storage (recovery) attempts withcause
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(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail next n read from storage (recovery) attempts withcause
exception for particular persistence id.
-
failNextNReads
public void failNextNReads(java.lang.String persistenceId, int n)
Fail next n read from storage (recovery) attempts with default exception for particular persistence id.
-
failNextDelete
public void failNextDelete(java.lang.Throwable cause)
Fail next delete from storage attempt withcause
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(java.lang.String persistenceId, java.lang.Throwable cause)
Fail next delete from storage attempt withcause
exception for particular persistence id.
-
failNextDelete
public void failNextDelete(java.lang.String persistenceId)
Fail next delete from storage attempt with default exception for particular persistence id.
-
failNextNDeletes
public void failNextNDeletes(int n, java.lang.Throwable cause)
Fail next n delete from storage attempts withcause
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(java.lang.String persistenceId, int n, java.lang.Throwable cause)
Fail next n delete from storage attempts withcause
exception for particular persistence id.
-
failNextNDeletes
public void failNextNDeletes(java.lang.String persistenceId, int n)
Fail next n delete from storage attempts with default exception for particular persistence id.
-
receivePersisted
public <A> java.util.List<A> receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla)
Receive nextn
snapshots that have been persisted in the storage.
-
receivePersisted
public <A> java.util.List<A> receivePersisted(java.lang.String persistenceId, int n, java.lang.Class<A> cla, java.time.Duration max)
Receive formax
time nextn
snapshots that have been persisted in the storage.
-
persistForRecovery
public void persistForRecovery(java.lang.String persistenceId, java.util.List<Pair<SnapshotMeta,java.lang.Object>> snapshots)
Persistsnapshots
with metadata into storage in order.
-
persistedInStorage
public java.util.List<Pair<SnapshotMeta,java.lang.Object>> persistedInStorage(java.lang.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(java.lang.String persistenceId)
Clear all data from storage for particular persistence id.
-
failNextNOpsCond
public void failNextNOpsCond(java.util.function.BiFunction<java.lang.String,SnapshotOperation,java.lang.Object> cond, int n)
Failn
following journal operations depending on the conditioncond
. Failure triggers, whencond
returns true. Fails operations with defaultExpectedFailure
exception.
-
failNextNOpsCond
public void failNextNOpsCond(java.util.function.BiFunction<java.lang.String,SnapshotOperation,java.lang.Object> cond, int n, java.lang.Throwable cause)
Failn
following journal operations depending on the conditioncond
. Failure triggers, whencond
returns true. Fails operations with thecause
exception.
-
failNextNOps
public void failNextNOps(int n)
Fail n following journal operations regardless of their type. Fails operations with defaultExpectedFailure
exception.
-
failNextNOps
public void failNextNOps(int n, java.lang.Throwable cause)
Failn
following journal operations depending on the conditioncond
. Failure triggers, whencond
returns true. Fails operations with thecause
exception.
-
withPolicy
public SnapshotTestKit withPolicy(ProcessingPolicy<SnapshotOperation> policy)
Set new processing policy for journal operations. NOTE! Overrides previously invokedfailNext...
orrejectNext...
-
resetPolicy
public void resetPolicy()
Returns default policy if it was changed by {@link SnapshotTestKit.withPolicy()}.
-
-