Class BidiStreamingMethodStubBuilderImpl<ReqT,RespT>
- All Implemented Interfaces:
BuilderStep,FirstRequestMatcherBuilderStep<BidiStreamingMethodStubBuilderStep<ReqT,,RespT>, ReqT> HeadersMatcherBuilderStep<BidiStreamingMethodStubBuilderStep<ReqT,,RespT>> BidiStreamingMethodStubBuilderStep<ReqT,,RespT> MethodStubBuilder<ReqT,,RespT> NextBidiStreamingMethodStubBuilderStep<ReqT,,RespT> NextStreamRequestProxyResponseBuilderStep<NextBidiStreamingMethodStubBuilderStep<ReqT,,RespT>, ReqT, RespT> StreamRequestProxyResponseBuilderStep<NextBidiStreamingMethodStubBuilderStep<ReqT,RespT>, ReqT, RespT>
- Author:
- Fadelis
-
Constructor Summary
ConstructorsConstructorDescriptionBidiStreamingMethodStubBuilderImpl(io.grpc.MethodDescriptor<ReqT, RespT> method) -
Method Summary
Modifier and TypeMethodDescriptionbuild()nextWillProxyTo(Function<io.grpc.stub.StreamObserver<RespT>, io.grpc.stub.StreamObserver<ReqT>> streamRequestResponseProxy) Defines a proxying response, which will proxy the request to givenResponsefor subsequent request call to this stub.willProxyTo(Function<io.grpc.stub.StreamObserver<RespT>, io.grpc.stub.StreamObserver<ReqT>> streamRequestResponseProxy) Defines a proxying response, which will proxy the request to givenResponse.withFirstRequest(Predicate<ReqT> requestPredicate) Adds a request matcher for the stub, which will trigger only if incoming first request satisfies givenPredicate.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.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.FirstRequestMatcherBuilderStep
withFirstRequestMethods inherited from interface org.grpcmock.definitions.matcher.steps.HeadersMatcherBuilderStep
withHeader, withHeader, withHeader, withHeader, withoutHeader, withoutHeader
-
Constructor Details
-
BidiStreamingMethodStubBuilderImpl
-
-
Method Details
-
withHeader
public <T> BidiStreamingMethodStubBuilderStep<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>
-
withFirstRequest
public BidiStreamingMethodStubBuilderStep<ReqT,RespT> withFirstRequest(@Nonnull Predicate<ReqT> requestPredicate) Description copied from interface:FirstRequestMatcherBuilderStepAdds a request matcher for the stub, which will trigger only if incoming first request satisfies given
Predicate.This is used for client or bidi streaming method calls. Only the first request can be used for matching, as a stub needs to be selected at this point or the call will be rejected.
Subsequent request matchers will replace the old one.
- Specified by:
withFirstRequestin interfaceFirstRequestMatcherBuilderStep<ReqT,RespT>
-
willProxyTo
public NextBidiStreamingMethodStubBuilderStep<ReqT,RespT> willProxyTo(@Nonnull Function<io.grpc.stub.StreamObserver<RespT>, io.grpc.stub.StreamObserver<ReqT>> streamRequestResponseProxy) Description copied from interface:StreamRequestProxyResponseBuilderStepDefines 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((responseObserver) -> new StreamObserver
() { public void onNext(V value) { // handle incoming requests } public void onError(Throwable throwable) { // handle error; } public void onCompleted() { // send response on completion responseObserver.onNext(responseObject); responseObserver.onCompleted(); } }); - Specified by:
willProxyToin interfaceStreamRequestProxyResponseBuilderStep<NextBidiStreamingMethodStubBuilderStep<ReqT,RespT>, ReqT, RespT>
-
nextWillProxyTo
public NextBidiStreamingMethodStubBuilderStep<ReqT,RespT> nextWillProxyTo(@Nonnull Function<io.grpc.stub.StreamObserver<RespT>, io.grpc.stub.StreamObserver<ReqT>> streamRequestResponseProxy) Description copied from interface:NextStreamRequestProxyResponseBuilderStepDefines 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((responseObserver) -> new StreamObserver
() { public void onNext(V value) { // handle incoming requests } public void onError(Throwable throwable) { // handle error; } public void onCompleted() { // send response on completion responseObserver.onNext(responseObject); responseObserver.onCompleted(); } }); - Specified by:
nextWillProxyToin interfaceNextStreamRequestProxyResponseBuilderStep<NextBidiStreamingMethodStubBuilderStep<ReqT,RespT>, ReqT, RespT>
-
build
- Specified by:
buildin interfaceMethodStubBuilder<ReqT,RespT>
-