Class ActionTestkit<A extends kalix.javasdk.action.Action>

Object
kalix.javasdk.testkit.ActionTestkit<A>

public class ActionTestkit<A extends kalix.javasdk.action.Action> extends Object
Action Testkit for use in unit tests for Actions.

To test an Action create a testkit instance by calling one of the available ActionTestkit.of methods. The returned testkit can be used as many times as you want. It doesn't preserve any state between invocations.

Use the call or stream methods to interact with the testkit.

  • Method Summary

    Modifier and Type
    Method
    Description
    <R> kalix.javasdk.testkit.ActionResult<R>
    call(Function<A,kalix.javasdk.action.Action.Effect<R>> func)
    The call method can be used to simulate a unary call to the Action.
    <R> kalix.javasdk.testkit.ActionResult<R>
    call(Function<A,kalix.javasdk.action.Action.Effect<R>> func, kalix.javasdk.Metadata metadata)
    The call method can be used to simulate a unary call to the Action.
    static <A extends kalix.javasdk.action.Action>
    ActionTestkit<A>
    of(Function<kalix.javasdk.action.ActionCreationContext,A> actionFactory)
     
    static <A extends kalix.javasdk.action.Action>
    ActionTestkit<A>
    of(Supplier<A> actionFactory)
     
    <R> reactor.core.publisher.Flux<kalix.javasdk.testkit.ActionResult<R>>
    streamedCall(Function<A,reactor.core.publisher.Flux<kalix.javasdk.action.Action.Effect<R>>> func)
    The streamedCall method can be used to simulate a streamed call to the Action.

    Methods inherited from class java.lang.Object

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

    • of

      public static <A extends kalix.javasdk.action.Action> ActionTestkit<A> of(Function<kalix.javasdk.action.ActionCreationContext,A> actionFactory)
    • of

      public static <A extends kalix.javasdk.action.Action> ActionTestkit<A> of(Supplier<A> actionFactory)
    • call

      public <R> kalix.javasdk.testkit.ActionResult<R> call(Function<A,kalix.javasdk.action.Action.Effect<R>> func)
      The call method can be used to simulate a unary call to the Action. The passed java lambda should return an Action.Effect. The Effect is interpreted into an ActionResult that can be used in test assertions.
      Type Parameters:
      R - The type of reply that is expected from invoking a command handler
      Parameters:
      func - A function from Action to Action.Effect
      Returns:
      an ActionResult
    • call

      public <R> kalix.javasdk.testkit.ActionResult<R> call(Function<A,kalix.javasdk.action.Action.Effect<R>> func, kalix.javasdk.Metadata metadata)
      The call method can be used to simulate a unary call to the Action. The passed java lambda should return an Action.Effect. The Effect is interpreted into an ActionResult that can be used in test assertions.
      Type Parameters:
      R - The type of reply that is expected from invoking a command handler
      Parameters:
      func - A function from Action to Action.Effect
      metadata - A metadata passed as a call context
      Returns:
      an ActionResult
    • streamedCall

      public <R> reactor.core.publisher.Flux<kalix.javasdk.testkit.ActionResult<R>> streamedCall(Function<A,reactor.core.publisher.Flux<kalix.javasdk.action.Action.Effect<R>>> func)
      The streamedCall method can be used to simulate a streamed call to the Action. The passed java lambda should return a Flux<Action.Effect>. The Flux<Action.Effect> is interpreted into an Flux<ActionResult> that can be used in test assertions.
      Type Parameters:
      R - The type of reply that is expected from invoking a command handler
      Parameters:
      func - A function from Flux<Action.Effect> to a Flux<ActionResult<R>>
      Returns:
      a Flux<ActionResult<R>>