Class UnaryMethodStubBuilderImpl<ReqT,RespT>
- All Implemented Interfaces:
BuilderStep,HeadersMatcherBuilderStep<UnaryMethodStubBuilderStep<ReqT,,RespT>> RequestMatcherBuilderStep<UnaryMethodStubBuilderStep<ReqT,,RespT>, ReqT> MethodStubBuilder<ReqT,,RespT> NextSingleRequestProxyResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,,RespT>, ReqT, RespT> NextSingleResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,,RespT>, ReqT, RespT> NextUnaryMethodResponseBuilderStep<ReqT,,RespT> SingleRequestProxyResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,,RespT>, ReqT, RespT> SingleResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,,RespT>, RespT> UnaryMethodStubBuilderStep<ReqT,RespT>
- Author:
- Fadelis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()nextWillProxyTo(BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> responseProxy) Defines a proxying response, which will proxy the request to givenResponsefor subsequent request call to this stub.nextWillReturn(ExceptionResponseActionBuilder response) Defines a exceptionResponsefor subsequent request call to this stub.nextWillReturn(ObjectResponseActionBuilder<RespT> response) Defines a singleResponsefor subsequent request call to this stub.willProxyTo(BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> responseProxy) Defines a proxying response, which will proxy the request to givenResponse.willReturn(ExceptionResponseActionBuilder response) Defines a exceptionResponsethat will terminate the request.willReturn(ObjectResponseActionBuilder<RespT> response) Defines a singleResponsethat will be returned for the request and complete it.withHeader(io.grpc.Metadata.Key<T> headerKey, Predicate<T> predicate) Adds a header matcher for the stub, which will trigger only if the given header has value satisfying givenPredicate.withRequest(Predicate<ReqT> requestPredicate) Adds a request matcher for the stub, which will trigger only if incoming request satisfies givenPredicate.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.grpcmock.definitions.matcher.steps.HeadersMatcherBuilderStep
withHeader, withHeader, withHeader, withHeader, withoutHeader, withoutHeaderMethods inherited from interface org.grpcmock.definitions.stub.steps.NextSingleRequestProxyResponseBuilderStep
nextWillReturnMethods inherited from interface org.grpcmock.definitions.stub.steps.NextSingleResponseBuilderStep
nextWillReturn, nextWillReturnMethods inherited from interface org.grpcmock.definitions.matcher.steps.RequestMatcherBuilderStep
withRequestMethods inherited from interface org.grpcmock.definitions.stub.steps.SingleRequestProxyResponseBuilderStep
willReturnMethods inherited from interface org.grpcmock.definitions.stub.steps.SingleResponseBuilderStep
willReturn, willReturn
-
Constructor Details
-
UnaryMethodStubBuilderImpl
-
-
Method Details
-
withHeader
public <T> UnaryMethodStubBuilderStep<ReqT,RespT> withHeader(@Nonnull io.grpc.Metadata.Key<T> headerKey, @Nonnull Predicate<T> predicate) Description copied from interface:HeadersMatcherBuilderStepAdds a header matcher for the stub, which will trigger only if the given header has value satisfying given
Predicate.Subsequent matchers for the same header will replace the old one.
- Specified by:
withHeaderin interfaceHeadersMatcherBuilderStep<ReqT>
-
withRequest
public UnaryMethodStubBuilderStep<ReqT,RespT> withRequest(@Nonnull Predicate<ReqT> requestPredicate) Description copied from interface:RequestMatcherBuilderStepAdds a request matcher for the stub, which will trigger only if incoming request satisfies given
Predicate.Only applicable to unary or server streaming methods.
Subsequent request matchers will replace the old one.
- Specified by:
withRequestin interfaceRequestMatcherBuilderStep<ReqT,RespT>
-
willReturn
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> willReturn(@Nonnull ObjectResponseActionBuilder<RespT> response) Description copied from interface:SingleResponseBuilderStepDefines a singleResponsethat will be returned for the request and complete it.- Specified by:
willReturnin interfaceSingleResponseBuilderStep<ReqT,RespT>
-
willReturn
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> willReturn(@Nonnull ExceptionResponseActionBuilder response) Description copied from interface:SingleResponseBuilderStepDefines a exceptionResponsethat will terminate the request.- Specified by:
willReturnin interfaceSingleResponseBuilderStep<ReqT,RespT>
-
nextWillReturn
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> nextWillReturn(@Nonnull ObjectResponseActionBuilder<RespT> response) Description copied from interface:NextSingleResponseBuilderStepDefines a single
Responsefor subsequent request call to this stub.If there are more requests coming in to this stub than responses defined, the last response defined will be returned for those requests.
- Specified by:
nextWillReturnin interfaceNextSingleResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
nextWillReturn
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> nextWillReturn(@Nonnull ExceptionResponseActionBuilder response) Description copied from interface:NextSingleResponseBuilderStepDefines a exception
Responsefor subsequent request call to this stub.If there are more requests coming in to this stub than responses defined, the last response defined will be returned for those requests.
- Specified by:
nextWillReturnin interfaceNextSingleResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
willProxyTo
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> willProxyTo(@Nonnull BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> responseProxy) Description copied from interface:SingleRequestProxyResponseBuilderStepDefines a proxying response, which will proxy the request to given
Response. The user is responsible that the request is completed correctly.Should be used when there needs to be more logic in the response method than returning a simple response. For example:
.willProxyTo((request, responseObserver) -> { responseObserver.onNext(responseObject); responseObserver.onCompleted(); });- Specified by:
willProxyToin interfaceSingleRequestProxyResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
nextWillProxyTo
public NextUnaryMethodResponseBuilderStep<ReqT,RespT> nextWillProxyTo(@Nonnull BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> responseProxy) Description copied from interface:NextSingleRequestProxyResponseBuilderStepDefines a proxying response, which will proxy the request to given
Responsefor subsequent request call to this stub. The user is responsible that the request is completed correctly.Should be used when there needs to be more logic in the response method than returning a simple response. For example:
.nextWillProxyTo((request, responseObserver) -> { responseObserver.onNext(responseObject); responseObserver.onCompleted(); });- Specified by:
nextWillProxyToin interfaceNextSingleRequestProxyResponseBuilderStep<NextUnaryMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
build
- Specified by:
buildin interfaceMethodStubBuilder<ReqT,RespT>
-