Class GrpcMock


  • public class GrpcMock
    extends java.lang.Object
    Filibuster wrapper for Grpc with a slightly different interface to allow for dynamically adjusting mocks when faults are injected. Designed for use with FilibusterGrpcTest and will not work in isolation (at the moment!)
    • Constructor Detail

      • GrpcMock

        public GrpcMock()
    • Method Detail

      • adjustExpectation

        public static <ReqT> void adjustExpectation​(@Nonnull
                                                    io.grpc.MethodDescriptor<ReqT,​?> method,
                                                    int count)
        Adjust the expected number of invocations specified using verifyThat.
        Parameters:
        method - the GRPC method descriptor
        count - 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 using verifyThat.
        Type Parameters:
        ReqT - the request type
        Parameters:
        method - the GRPC method descriptor
        request - the request
        count - the number of expected invocations
      • 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 type
        RespT - the response type
        Parameters:
        method - the GRPC method descriptor
        request - the request
        response - 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 descriptor
        count - 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 descriptor
        request - the request
        count - the number of expected invocations