Package kalix.javasdk.testkit
Class KalixTestKit
Object
kalix.javasdk.testkit.KalixTestKit
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Settings for KalixTestkit. -
Constructor Summary
ConstructorDescriptionKalixTestKit
(kalix.javasdk.Kalix kalix) Create a new testkit for a Kalix service descriptor.KalixTestKit
(kalix.javasdk.Kalix kalix, kalix.javasdk.impl.MessageCodec messageCodec, KalixTestKit.Settings settings) Create a new testkit for a Kalix service descriptor with custom settings.KalixTestKit
(kalix.javasdk.Kalix kalix, KalixTestKit.Settings settings) Create a new testkit for a Kalix service descriptor with custom settings. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Get an available local port for testing.akka.actor.ActorSystem
Get anActorSystem
for creating Akka HTTP clients.Get incoming messages for EventSourcedEntity.<T> T
getGrpcClient
(Class<T> clientClass) Get an Akka gRPC client for the given service name.<T> T
getGrpcClientForPrincipal
(Class<T> clientClass, kalix.javasdk.Principal principal) Get an Akka gRPC client for the given service name, authenticating using the given principal.getHost()
Get the host name/IP address where the Kalix service is available.akka.stream.Materializer
An Akka Stream materializer to use for running streams.ReturnsEventingTestKit.MessageBuilder
utility to createEventingTestKit.Message
s for the eventing testkit.kalix.javasdk.impl.MessageCodec
INTERNAL APIint
getPort()
Get the local port where the Kalix service is available.kalix.javasdk.KalixRunner
INTERNAL APIgetStreamIncomingMessages
(String service, String streamId) Get incoming messages for Stream (eventing.in.direct in case of protobuf SDKs).getTopicIncomingMessages
(String topic) Get incoming messages for Topic.getTopicOutgoingMessages
(String topic) Get mocked topic destination.getValueEntityIncomingMessages
(String typeId) Get incoming messages for ValueEntity.start()
Start this testkit with default configuration (loaded fromapplication.conf
).start
(com.typesafe.config.Config config) Start this testkit with custom configuration (overridesapplication.conf
).void
stop()
Stop the testkit and local Kalix.
-
Constructor Details
-
KalixTestKit
public KalixTestKit(kalix.javasdk.Kalix kalix) Create a new testkit for a Kalix service descriptor.- Parameters:
kalix
- Kalix service descriptor
-
KalixTestKit
Create a new testkit for a Kalix service descriptor with custom settings.- Parameters:
kalix
- Kalix service descriptorsettings
- custom testkit settings
-
KalixTestKit
public KalixTestKit(kalix.javasdk.Kalix kalix, kalix.javasdk.impl.MessageCodec messageCodec, KalixTestKit.Settings settings) Create a new testkit for a Kalix service descriptor with custom settings.- Parameters:
kalix
- Kalix service descriptormessageCodec
- message codecsettings
- custom testkit settings
-
-
Method Details
-
start
Start this testkit with default configuration (loaded fromapplication.conf
).- Returns:
- this KalixTestkit
-
start
Start this testkit with custom configuration (overridesapplication.conf
).- Parameters:
config
- custom test configuration for the KalixRunner- Returns:
- this KalixTestkit
-
getHost
Get the host name/IP address where the Kalix service is available. This is relevant in certain Continuous Integration environments.- Returns:
- Kalix host
-
getPort
public int getPort()Get the local port where the Kalix service is available.- Returns:
- local Kalix port
-
getGrpcClient
Get an Akka gRPC client for the given service name. The same client instance is shared for the test. The lifecycle of the client is managed by the SDK and it should not be stopped by user code.- Type Parameters:
T
- The "service" interface generated for the service by Akka gRPC- Parameters:
clientClass
- The class of a gRPC service generated by Akka gRPC
-
getGrpcClientForPrincipal
Get an Akka gRPC client for the given service name, authenticating using the given principal. The same client instance is shared for the test. The lifecycle of the client is managed by the SDK and it should not be stopped by user code.- Type Parameters:
T
- The "service" interface generated for the service by Akka gRPC- Parameters:
clientClass
- The class of a gRPC service generated by Akka gRPCprincipal
- The principal to authenticate calls to the service as.
-
getMaterializer
public akka.stream.Materializer getMaterializer()An Akka Stream materializer to use for running streams. Needed for example in a command handler which accepts streaming elements but returns a single async reply once all streamed elements has been consumed. -
getActorSystem
public akka.actor.ActorSystem getActorSystem()Get anActorSystem
for creating Akka HTTP clients.- Returns:
- test actor system
-
getValueEntityIncomingMessages
Get incoming messages for ValueEntity.- Parameters:
typeId
- @TypeId or entity_type of the ValueEntity (depending on the used SDK)
-
getEventSourcedEntityIncomingMessages
Get incoming messages for EventSourcedEntity.- Parameters:
typeId
- @TypeId or entity_type of the EventSourcedEntity (depending on the used SDK)
-
getStreamIncomingMessages
Get incoming messages for Stream (eventing.in.direct in case of protobuf SDKs).- Parameters:
service
- service namestreamId
- service stream id
-
getTopicIncomingMessages
Get incoming messages for Topic.- Parameters:
topic
- topic name
-
getTopicOutgoingMessages
Get mocked topic destination.- Parameters:
topic
- topic name
-
stop
public void stop()Stop the testkit and local Kalix. -
availableLocalPort
public static int availableLocalPort()Get an available local port for testing.- Returns:
- available local port
-
getMessageCodec
@InternalApi public kalix.javasdk.impl.MessageCodec getMessageCodec()INTERNAL API -
getRunner
@InternalApi public kalix.javasdk.KalixRunner getRunner()INTERNAL API -
getMessageBuilder
ReturnsEventingTestKit.MessageBuilder
utility to createEventingTestKit.Message
s for the eventing testkit.
-