@Test @SuppressWarnings("unchecked") public void shouldSupplyHandlerForMethodWithNoRequest() { ServerStreamingMethodHandlerSupplier supplier = new ServerStreamingMethodHandlerSupplier(); AnnotatedMethod method = getMethod("serverStreamingNoRequest", StreamObserver.class); Service service = mock(Service.class); MethodHandler<String, Long> handler = supplier.get("foo", method, () -> service); assertThat(handler, is(notNullValue())); assertThat(handler.getRequestType(), equalTo(Empty.class)); assertThat(handler.getResponseType(), equalTo(Long.class)); assertThat(handler.type(), equalTo(MethodDescriptor.MethodType.SERVER_STREAMING)); StreamObserver<Long> observer = mock(StreamObserver.class); handler.invoke("foo", observer); verify(service).serverStreamingNoRequest(any(StreamObserver.class)); }
@Override public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a server streaming method: " + method); } CallType type = determineCallType(method); MethodHandler<ReqT, RespT> handler; switch (type) { case serverStreaming: handler = new ServerStreaming<>(methodName, method, instance); break; case serverStreamingNoRequest: handler = new ServerStreamingNoRequest<>(methodName, method, instance); break; case streamResponse: handler = new StreamResponse<>(methodName, method, instance); break; case streamResponseNoRequest: handler = new StreamResponseNoRequest<>(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported server streaming method signature: " + method); } return handler; }
ServerStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a server streaming method: " + method); } CallType type = determineCallType(method); MethodHandler<ReqT, RespT> handler; switch (type) { case serverStreaming: handler = new ServerStreaming<>(methodName, method, instance); break; case serverStreamingNoRequest: handler = new ServerStreamingNoRequest<>(methodName, method, instance); break; case streamResponse: handler = new StreamResponse<>(methodName, method, instance); break; case streamResponseNoRequest: handler = new StreamResponseNoRequest<>(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported server streaming method signature: " + method); } return handler; } }
ServerStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a server streaming method: " + method); } CallType type = determineCallType(method); MethodHandler<ReqT, RespT> handler; switch (type) { case serverStreaming: handler = new ServerStreaming<>(methodName, method, instance); break; case serverStreamingNoRequest: handler = new ServerStreamingNoRequest<>(methodName, method, instance); break; case streamResponse: handler = new StreamResponse<>(methodName, method, instance); break; case streamResponseNoRequest: handler = new StreamResponseNoRequest<>(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported server streaming method signature: " + method); } return handler; } ServerStreamingMethodHandlerSupplier(); }
ServerStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a server streaming method: " + method); } CallType type = determineCallType(method); MethodHandler<ReqT, RespT> handler; switch (type) { case serverStreaming: handler = new ServerStreaming<>(methodName, method, instance); break; case serverStreamingNoRequest: handler = new ServerStreamingNoRequest<>(methodName, method, instance); break; case streamResponse: handler = new StreamResponse<>(methodName, method, instance); break; case streamResponseNoRequest: handler = new StreamResponseNoRequest<>(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported server streaming method signature: " + method); } return handler; } ServerStreamingMethodHandlerSupplier(); @Override boolean supplies(AnnotatedMethod method); @Override MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance); }
ServerStreamingMethodHandlerSupplier extends AbstractMethodHandlerSupplier { @Override public <ReqT, RespT> MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance) { if (!isRequiredMethodType(method)) { throw new IllegalArgumentException("Method not annotated as a server streaming method: " + method); } CallType type = determineCallType(method); MethodHandler<ReqT, RespT> handler; switch (type) { case serverStreaming: handler = new ServerStreaming<>(methodName, method, instance); break; case serverStreamingNoRequest: handler = new ServerStreamingNoRequest<>(methodName, method, instance); break; case streamResponse: handler = new StreamResponse<>(methodName, method, instance); break; case streamResponseNoRequest: handler = new StreamResponseNoRequest<>(methodName, method, instance); break; case unknown: default: throw new IllegalArgumentException("Not a supported server streaming method signature: " + method); } return handler; } ServerStreamingMethodHandlerSupplier(); @Override boolean supplies(AnnotatedMethod method); @Override MethodHandler<ReqT, RespT> get(String methodName, AnnotatedMethod method, Supplier<?> instance);  }