### Question:
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncUnaryCall( UnaryMethod<ReqT, RespT> method) { return asyncUnaryRequestCall(method); } private  ServerCalls(); static ServerCallHandler<ReqT, RespT> asyncUnaryCall(
      UnaryMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncServerStreamingCall(
      ServerStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncClientStreamingCall(
      ClientStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      BidiStreamingMethod<ReqT, RespT> method); static void asyncUnimplementedUnaryCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver); static StreamObserver<T> asyncUnimplementedStreamingCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver);  }### Answer:
@Test public void disablingInboundAutoFlowControlForUnaryHasNoEffect() throws Exception { ServerCallHandler<Integer, Integer> callHandler = ServerCalls.asyncUnaryCall( new ServerCalls.UnaryMethod<Integer, Integer>() { @Override public void invoke(Integer req, StreamObserver<Integer> responseObserver) { ServerCallStreamObserver<Integer> serverCallObserver = (ServerCallStreamObserver<Integer>) responseObserver; serverCallObserver.disableAutoInboundFlowControl(); } }); callHandler.startCall(serverCall, new Metadata()); assertThat(serverCall.requestCalls).containsExactly(2); }
@Test public void clientSendsOne_errorMissingRequest_unary() { ServerCallRecorder serverCall = new ServerCallRecorder(UNARY_METHOD); ServerCallHandler<Integer, Integer> callHandler = ServerCalls.asyncUnaryCall( new ServerCalls.UnaryMethod<Integer, Integer>() { @Override public void invoke(Integer req, StreamObserver<Integer> responseObserver) { fail("should not be reached"); } }); ServerCall.Listener<Integer> listener = callHandler.startCall(serverCall, new Metadata()); listener.onHalfClose(); assertThat(serverCall.responses).isEmpty(); assertEquals(Status.Code.INTERNAL, serverCall.status.getCode()); assertEquals(ServerCalls.MISSING_REQUEST, serverCall.status.getDescription()); }
@Test public void clientSendsOne_errorTooManyRequests_unary() { ServerCallRecorder serverCall = new ServerCallRecorder(UNARY_METHOD); ServerCallHandler<Integer, Integer> callHandler = ServerCalls.asyncUnaryCall( new ServerCalls.UnaryMethod<Integer, Integer>() { @Override public void invoke(Integer req, StreamObserver<Integer> responseObserver) { fail("should not be reached"); } }); ServerCall.Listener<Integer> listener = callHandler.startCall(serverCall, new Metadata()); listener.onMessage(1); listener.onMessage(1); assertThat(serverCall.responses).isEmpty(); assertEquals(Status.Code.INTERNAL, serverCall.status.getCode()); assertEquals(ServerCalls.TOO_MANY_REQUESTS, serverCall.status.getDescription()); listener.onHalfClose(); }