Package cloud.filibuster.junit.statem
Class GrpcMock
- java.lang.Object
-
- cloud.filibuster.junit.statem.GrpcMock
-
public class GrpcMock extends java.lang.Object
Filibuster wrapper forGrpc
with a slightly different interface to allow for dynamically adjusting mocks when faults are injected. Designed for use withFilibusterGrpcTest
and will not work in isolation (at the moment!)
-
-
Constructor Summary
Constructors Constructor Description GrpcMock()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <ReqT> void
adjustExpectation(io.grpc.MethodDescriptor<ReqT,?> method, int count)
Adjust the expected number of invocations specified usingverifyThat
.static <ReqT> void
adjustExpectation(io.grpc.MethodDescriptor<ReqT,?> method, ReqT request, int count)
Adjust the expected number of invocations specified usingverifyThat
.static java.util.Map<java.lang.String,java.lang.Boolean>
getVerifyThatMapping()
Return the mapping containing whether all stubs have had eitherverifyThat(MethodDescriptor, int)
orverifyThat(MethodDescriptor, ReqT, int)
invoked on them.static void
resetAdjustedExpectations()
Clear out expectations for stub invocations made usingadjustExpectation(MethodDescriptor, int)
oradjustExpectation(MethodDescriptor, ReqT, int)
.static void
resetVerifyThatMapping()
Clear out expectations for stub invocations made usingverifyThat(MethodDescriptor, int)
orverifyThat(MethodDescriptor, ReqT, int)
.static <ReqT,RespT>
voidstubFor(io.grpc.MethodDescriptor<ReqT,RespT> method, ReqT request, RespT response)
Stub a GRPC method with a given request providing a particular response.static <ReqT> void
verifyThat(io.grpc.MethodDescriptor<ReqT,?> method, int count)
Set an expectation that a stub will be invoked a particular number of times.static <ReqT> void
verifyThat(io.grpc.MethodDescriptor<ReqT,?> method, ReqT request, int count)
Set an expectation that a stub will be invoked, with a given request, a particular number of times.
-
-
-
Method Detail
-
resetAdjustedExpectations
public static void resetAdjustedExpectations()
Clear out expectations for stub invocations made usingadjustExpectation(MethodDescriptor, int)
oradjustExpectation(MethodDescriptor, ReqT, int)
. Called implicitly byFilibusterGrpcTest.execute()
.
-
adjustExpectation
public static <ReqT> void adjustExpectation(@Nonnull io.grpc.MethodDescriptor<ReqT,?> method, int count)
Adjust the expected number of invocations specified usingverifyThat
.- Parameters:
method
- the GRPC method descriptorcount
- the number of expected invocations
-
adjustExpectation
public static <ReqT> void adjustExpectation(@Nonnull io.grpc.MethodDescriptor<ReqT,?> method, @Nonnull ReqT request, int count)
Adjust the expected number of invocations specified usingverifyThat
.- Type Parameters:
ReqT
- the request type- Parameters:
method
- the GRPC method descriptorrequest
- the requestcount
- the number of expected invocations
-
getVerifyThatMapping
public static java.util.Map<java.lang.String,java.lang.Boolean> getVerifyThatMapping()
Return the mapping containing whether all stubs have had eitherverifyThat(MethodDescriptor, int)
orverifyThat(MethodDescriptor, ReqT, int)
invoked on them.- Returns:
verifyThatMapping
-
resetVerifyThatMapping
public static void resetVerifyThatMapping()
Clear out expectations for stub invocations made usingverifyThat(MethodDescriptor, int)
orverifyThat(MethodDescriptor, ReqT, int)
. Called implicitly byFilibusterGrpcTest.execute()
.
-
stubFor
public static <ReqT,RespT> void stubFor(@Nonnull io.grpc.MethodDescriptor<ReqT,RespT> method, @Nonnull ReqT request, @Nonnull RespT response)
Stub a GRPC method with a given request providing a particular response.- Type Parameters:
ReqT
- the request typeRespT
- the response type- Parameters:
method
- the GRPC method descriptorrequest
- the requestresponse
- the response
-
verifyThat
public static <ReqT> void verifyThat(@Nonnull io.grpc.MethodDescriptor<ReqT,?> method, int count)
Set an expectation that a stub will be invoked a particular number of times. This function prohibits the developer stating "any times" and requires a precise invocation count.- Type Parameters:
ReqT
- the request type- Parameters:
method
- the GRPC method descriptorcount
- the number of expected invocations
-
verifyThat
public static <ReqT> void verifyThat(@Nonnull io.grpc.MethodDescriptor<ReqT,?> method, @Nonnull ReqT request, int count)
Set an expectation that a stub will be invoked, with a given request, a particular number of times. This function prohibits the developer stating "any times" and requires a precise invocation count.- Type Parameters:
ReqT
- the request type- Parameters:
method
- the GRPC method descriptorrequest
- the requestcount
- the number of expected invocations
-
-