@Test public void shouldSupplyClientStreamingHandlerWithTypesFromAnnotation() { ClientStreamingMethodHandlerSupplier supplier = new ClientStreamingMethodHandlerSupplier(); AnnotatedMethod method = getMethod("reqResp", StreamObserver.class); Service service = mock(Service.class); MethodHandler<String, String> handler = supplier.get("foo", method, () -> service); assertThat(handler, is(notNullValue())); assertThat(Long.class.equals(handler.getRequestType()), is(true)); assertThat(String.class.equals(handler.getResponseType()), is(true)); }
@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);  }