Package kalix.springsdk.testkit
Class ActionTestkit<A extends kalix.javasdk.action.Action>
- Object
-
- kalix.springsdk.testkit.ActionTestkit<A>
-
public class ActionTestkit<A extends kalix.javasdk.action.Action> extends ObjectAction Testkit for use in unit tests for Actions.To test an Action create a testkit instance by calling one of the available
ActionTestkit.ofmethods. The returned testkit can be used as many times as you want. It doesn't preserve any state between invocations.Use the
call or streammethods 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)Thecallmethod 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)ThestreamedCallmethod can be used to simulate a streamed call to the Action.
-
-
-
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)
Thecallmethod 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)
ThestreamedCallmethod can be used to simulate a streamed call to the Action. The passed java lambda should return aFlux<Action.Effect>. TheFlux<Action.Effect>is interpreted into anFlux<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 fromFlux<Action.Effect>to aFlux<ActionResult<R>>- Returns:
- a
Flux<ActionResult<R>>
-
-