Package akka.javasdk.testkit
Interface MockedGrpcServices
@DoNotInherit
public interface MockedGrpcServices
Registry of mocked gRPC services for a running
TestKit. Lets individual tests install or
replace mock instances without re-creating the testkit.
Entries declared via TestKit.Settings.withMockedGrpcService(String, Class, AkkaGrpcClient) are used to seed the registry at testkit startup and are restored by reset().
The mock instance is shared across calls and method invocations can overlap when the service under test issues concurrent requests, so any state shared between the mock and the test class (captured fields, counters, queues) must be thread-safe.
Not for user extension.
-
Method Summary
Modifier and TypeMethodDescription<T extends akka.grpc.javadsl.AkkaGrpcClient>
voidmockResponse(String serviceName, Class<T> serviceClass, T mockInstance) Register or replace a mock instance for calls made throughgrpcClientProvider.grpcClientFor(serviceClass, serviceName).<T extends akka.grpc.javadsl.AkkaGrpcClient>
voidRemove the mock for the given service name and client class, if any.voidreset()Reset the registry back to the mocks declared inTestKit.Settings.
-
Method Details
-
mockResponse
<T extends akka.grpc.javadsl.AkkaGrpcClient> void mockResponse(String serviceName, Class<T> serviceClass, T mockInstance) Register or replace a mock instance for calls made throughgrpcClientProvider.grpcClientFor(serviceClass, serviceName). -
remove
Remove the mock for the given service name and client class, if any. -
reset
void reset()Reset the registry back to the mocks declared inTestKit.Settings.
-