@Test @SuppressWarnings("unchecked") public void shouldSupplyClientStreamingHandler() { ClientStreamingMethodHandlerSupplier supplier = new ClientStreamingMethodHandlerSupplier(); AnnotatedMethod method = getClientStreamingMethod(); StreamObserver<Long> responseObserver = mock(StreamObserver.class); Service service = mock(Service.class); when(service.clientStreaming(any(StreamObserver.class))).thenReturn(responseObserver); MethodHandler<Long, String> handler = supplier.get("foo", method, () -> service); assertThat(handler, is(notNullValue())); assertThat(handler.getRequestType(), equalTo(Long.class)); assertThat(handler.getResponseType(), equalTo(String.class)); assertThat(handler.type(), equalTo(MethodDescriptor.MethodType.CLIENT_STREAMING)); StreamObserver<String> observer = mock(StreamObserver.class); StreamObserver<Long> result = handler.invoke(observer); assertThat(result, is(sameInstance(responseObserver))); verify(service).clientStreaming(any(StreamObserver.class)); }
@Override @SuppressWarnings("unchecked") public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a client streaming method: " + method); } CallType type = determineCallType(method); MethodHandler handler; switch (type) { case clientStreaming: handler = new ClientStreaming<>(methodName, method, instance); break; case futureResponse: handler = new FutureResponse<>(methodName, method, instance); break; case clientStreamingIterable: handler = new ClientStreamingIterable(methodName, method, instance); break; case clientStreamingStream: handler = new ClientStreamingStream(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported client streaming method signature: " + method); } return handler; }
ClientStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override @SuppressWarnings("unchecked") public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a client streaming method: " + method); } CallType type = determineCallType(method); MethodHandler handler; switch (type) { case clientStreaming: handler = new ClientStreaming<>(methodName, method, instance); break; case futureResponse: handler = new FutureResponse<>(methodName, method, instance); break; case clientStreamingIterable: handler = new ClientStreamingIterable(methodName, method, instance); break; case clientStreamingStream: handler = new ClientStreamingStream(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported client streaming method signature: " + method); } return handler; } }
ClientStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override @SuppressWarnings("unchecked") public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a client streaming method: " + method); } CallType type = determineCallType(method); MethodHandler handler; switch (type) { case clientStreaming: handler = new ClientStreaming<>(methodName, method, instance); break; case futureResponse: handler = new FutureResponse<>(methodName, method, instance); break; case clientStreamingIterable: handler = new ClientStreamingIterable(methodName, method, instance); break; case clientStreamingStream: handler = new ClientStreamingStream(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported client streaming method signature: " + method); } return handler; } ClientStreamingMethodHandlerSupplier(); }
ClientStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override @SuppressWarnings("unchecked") public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a client streaming method: " + method); } CallType type = determineCallType(method); MethodHandler handler; switch (type) { case clientStreaming: handler = new ClientStreaming<>(methodName, method, instance); break; case futureResponse: handler = new FutureResponse<>(methodName, method, instance); break; case clientStreamingIterable: handler = new ClientStreamingIterable(methodName, method, instance); break; case clientStreamingStream: handler = new ClientStreamingStream(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported client streaming method signature: " + method); } return handler; } ClientStreamingMethodHandlerSupplier(); @Override boolean supplies(AnnotatedMethod method); @Override @SuppressWarnings("unchecked") MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance); }
ClientStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override @SuppressWarnings("unchecked") public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a client streaming method: " + method); } CallType type = determineCallType(method); MethodHandler handler; switch (type) { case clientStreaming: handler = new ClientStreaming<>(methodName, method, instance); break; case futureResponse: handler = new FutureResponse<>(methodName, method, instance); break; case clientStreamingIterable: handler = new ClientStreamingIterable(methodName, method, instance); break; case clientStreamingStream: handler = new ClientStreamingStream(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported client streaming method signature: " + method); } return handler; } ClientStreamingMethodHandlerSupplier(); @Override boolean supplies(AnnotatedMethod method); @Override @SuppressWarnings("unchecked") MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance);  }