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 Classes
    Modifier and Type
    Class
    Description
    final class 
     
    final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    boolean
     
    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.
    method(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.
    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.
    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.
    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.
    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.
    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's emptyState().
    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's emptyState().
    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's emptyState().
    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's emptyState().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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's emptyState(). Subsequent deleteEntity() effects still reset the state to the entity's emptyState().

      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's emptyState(). Subsequent deleteEntity() effects still reset the state to the entity's emptyState().

      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's emptyState(). Subsequent deleteEntity() effects still reset the state to the entity's emptyState().
    • 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's emptyState(). Subsequent deleteEntity() effects still reset the state to the entity's emptyState().
    • getState

      public S 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,R> method(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