Package akka.javasdk.testkit
Class KeyValueEntityTestKit<S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
Object
akka.javasdk.testkit.KeyValueEntityTestKit<S,E>
public class KeyValueEntityTestKit<S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
extends Object
KeyValueEntity Testkit for use in unit tests for Value entities.
To test a KeyValueEntity create a testkit instance by calling one of the available
KeyValueEntityTestKit.of methods. The returned testkit is stateful, and it holds internally the
state of the entity.
Use the method methods to interact with the testkit.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classfinal class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetState()boolean<R> KeyValueEntityTestKit<S,E>.MethodRef <R> Pass in a Key Value Entity command handler method reference without parameters, e.g.<I,R> KeyValueEntityTestKit<S, E>.MethodRef1 <I, R> Pass in a Key Value Entity command handler method reference with a single parameter, e.g.static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> Creates a new testkit instance from a user defined entity id and a function KeyValueEntityContext to KeyValueEntity.static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> Creates a new testkit instance from a user defined entity id and a KeyValueEntity Supplier.static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> Creates a new testkit instance from a function KeyValueEntityContext to KeyValueEntity.static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> Creates a new testkit instance from a KeyValueEntity Supplier.static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> ofEntityWithState(String entityId, Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory, S initialState) Creates a new testkit instance from a user defined entity id and a function KeyValueEntityContext to KeyValueEntity, starting with the given initial state instead of the entity'semptyState().static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> ofEntityWithState(String entityId, Supplier<E> entityFactory, S initialState) Creates a new testkit instance from a user defined entity id and a KeyValueEntity Supplier, starting with the given initial state instead of the entity'semptyState().static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> ofEntityWithState(Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory, S initialState) Creates a new testkit instance from a function KeyValueEntityContext to KeyValueEntity, starting with the given initial state instead of the entity'semptyState().static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>>
KeyValueEntityTestKit<S, E> ofEntityWithState(Supplier<E> entityFactory, S initialState) Creates a new testkit instance from a KeyValueEntity Supplier, starting with the given initial state instead of the entity'semptyState().
-
Field Details
-
DEFAULT_TEST_ENTITY_ID
- See Also:
-
-
Method Details
-
of
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> of(Supplier<E> entityFactory) Creates a new testkit instance from a KeyValueEntity Supplier.A default test entity id will be automatically provided.
-
of
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> of(Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory) Creates a new testkit instance from a function KeyValueEntityContext to KeyValueEntity.A default test entity id will be automatically provided.
-
of
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> of(String entityId, Supplier<E> entityFactory) Creates a new testkit instance from a user defined entity id and a KeyValueEntity Supplier. -
of
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> of(String entityId, Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory) Creates a new testkit instance from a user defined entity id and a function KeyValueEntityContext to KeyValueEntity. -
ofEntityWithState
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> ofEntityWithState(Supplier<E> entityFactory, S initialState) Creates a new testkit instance from a KeyValueEntity Supplier, starting with the given initial state instead of the entity'semptyState(). SubsequentdeleteEntity()effects still reset the state to the entity'semptyState().A default test entity id will be automatically provided.
-
ofEntityWithState
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> ofEntityWithState(Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory, S initialState) Creates a new testkit instance from a function KeyValueEntityContext to KeyValueEntity, starting with the given initial state instead of the entity'semptyState(). SubsequentdeleteEntity()effects still reset the state to the entity'semptyState().A default test entity id will be automatically provided.
-
ofEntityWithState
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> ofEntityWithState(String entityId, Supplier<E> entityFactory, S initialState) Creates a new testkit instance from a user defined entity id and a KeyValueEntity Supplier, starting with the given initial state instead of the entity'semptyState(). SubsequentdeleteEntity()effects still reset the state to the entity'semptyState(). -
ofEntityWithState
public static <S,E extends akka.javasdk.keyvalueentity.KeyValueEntity<S>> KeyValueEntityTestKit<S,E> ofEntityWithState(String entityId, Function<akka.javasdk.keyvalueentity.KeyValueEntityContext, E> entityFactory, S initialState) Creates a new testkit instance from a user defined entity id and a function KeyValueEntityContext to KeyValueEntity, starting with the given initial state instead of the entity'semptyState(). SubsequentdeleteEntity()effects still reset the state to the entity'semptyState(). -
getState
- Returns:
- The current state of the key value entity under test
-
isDeleted
public boolean isDeleted()- Returns:
- true if the entity is deleted
-
method
public <R> KeyValueEntityTestKit<S,E>.MethodRef<R> method(akka.japi.function.Function<E, akka.javasdk.keyvalueentity.KeyValueEntity.Effect<R>> func) Pass in a Key Value Entity command handler method reference without parameters, e.g.UserEntity::create -
method
public <I,R> KeyValueEntityTestKit<S,E>.MethodRef1<I, methodR> (akka.japi.function.Function2<E, I, akka.javasdk.keyvalueentity.KeyValueEntity.Effect<R>> func) Pass in a Key Value Entity command handler method reference with a single parameter, e.g.UserEntity::create
-