Class ClientStreamingMethodStubBuilderImpl<ReqT,RespT>
- All Implemented Interfaces:
BuilderStep,FirstRequestMatcherBuilderStep<ClientStreamingMethodStubBuilderStep<ReqT,,RespT>, ReqT> HeadersMatcherBuilderStep<ClientStreamingMethodStubBuilderStep<ReqT,,RespT>> ClientStreamingMethodStubBuilderStep<ReqT,,RespT> MethodStubBuilder<ReqT,,RespT> NextClientStreamingMethodResponseBuilderStep<ReqT,,RespT> NextSingleResponseBuilderStep<NextClientStreamingMethodResponseBuilderStep<ReqT,,RespT>, ReqT, RespT> NextStreamRequestProxyResponseBuilderStep<NextClientStreamingMethodResponseBuilderStep<ReqT,,RespT>, ReqT, RespT> SingleResponseBuilderStep<NextClientStreamingMethodResponseBuilderStep<ReqT,,RespT>, RespT> StreamRequestProxyResponseBuilderStep<NextClientStreamingMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
- Author:
- Fadelis
-
Constructor Summary
ConstructorsConstructorDescriptionClientStreamingMethodStubBuilderImpl(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.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(Function<io.grpc.stub.StreamObserver<RespT>, io.grpc.stub.StreamObserver<ReqT>> streamRequestResponseProxy) 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.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, withoutHeaderMethods inherited from interface org.grpcmock.definitions.stub.steps.NextSingleResponseBuilderStep
nextWillReturn, nextWillReturnMethods inherited from interface org.grpcmock.definitions.stub.steps.SingleResponseBuilderStep
willReturn, willReturn
-
Constructor Details
-
ClientStreamingMethodStubBuilderImpl
-
-
Method Details
-
withHeader
public <T> ClientStreamingMethodStubBuilderStep<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 ClientStreamingMethodStubBuilderStep<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>
-
willReturn
public NextClientStreamingMethodResponseBuilderStep<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 NextClientStreamingMethodResponseBuilderStep<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 NextClientStreamingMethodResponseBuilderStep<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<NextClientStreamingMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
nextWillReturn
public NextClientStreamingMethodResponseBuilderStep<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<NextClientStreamingMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
willProxyTo
public NextClientStreamingMethodResponseBuilderStep<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<NextClientStreamingMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
nextWillProxyTo
public NextClientStreamingMethodResponseBuilderStep<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<NextClientStreamingMethodResponseBuilderStep<ReqT,RespT>, ReqT, RespT>
-
build
- Specified by:
buildin interfaceMethodStubBuilder<ReqT,RespT>
-