@Test public void shouldNotSupplyMethodAnnotatedMethodWithTooManyArgs() { ClientStreamingMethodHandlerSupplier supplier = new ClientStreamingMethodHandlerSupplier(); AnnotatedMethod method = getMethod("tooManyArgs", StreamObserver.class, String.class); Service service = mock(Service.class); assertThrows(IllegalArgumentException.class, () -> supplier.get("foo", method, () -> service)); }
@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);  }