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


  • 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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <R> kalix.javasdk.testkit.ActionResult<R> call​(java.util.function.Function<A,​kalix.javasdk.action.Action.Effect<R>> func)
      The call method can be used to simulate a unary call to the Action.
      static <A extends kalix.javasdk.action.Action>
      ActionTestkit<A>
      of​(java.util.function.Function<kalix.javasdk.action.ActionCreationContext,​A> actionFactory)  
      static <A extends kalix.javasdk.action.Action>
      ActionTestkit<A>
      of​(java.util.function.Supplier<A> actionFactory)  
      <R> reactor.core.publisher.Flux<kalix.javasdk.testkit.ActionResult<R>> streamedCall​(java.util.function.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 Detail

      • of

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

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

        public <R> kalix.javasdk.testkit.ActionResult<R> call​(java.util.function.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
      • streamedCall

        public <R> reactor.core.publisher.Flux<kalix.javasdk.testkit.ActionResult<R>> streamedCall​(java.util.function.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>>