@Test public void runtimeStreamObserverIsServerCallStreamObserver() throws Exception { final AtomicBoolean invokeCalled = new AtomicBoolean(); final AtomicBoolean onCancelCalled = new AtomicBoolean(); final AtomicBoolean onReadyCalled = new AtomicBoolean(); final AtomicReference<ServerCallStreamObserver<Integer>> callObserver = new AtomicReference<ServerCallStreamObserver<Integer>>(); ServerCallHandler<Integer, Integer> callHandler = ServerCalls.asyncBidiStreamingCall( new ServerCalls.BidiStreamingMethod<Integer, Integer>() { @Override public StreamObserver<Integer> invoke(StreamObserver<Integer> responseObserver) { assertTrue(responseObserver instanceof ServerCallStreamObserver); ServerCallStreamObserver<Integer> serverCallObserver = (ServerCallStreamObserver<Integer>) responseObserver; callObserver.set(serverCallObserver); serverCallObserver.setOnCancelHandler(new Runnable() { @Override public void run() { onCancelCalled.set(true); } }); serverCallObserver.setOnReadyHandler(new Runnable() { @Override public void run() { onReadyCalled.set(true); } }); invokeCalled.set(true); return new ServerCalls.NoopStreamObserver<Integer>(); } }); ServerCall.Listener<Integer> callListener = callHandler.startCall(STREAMING_METHOD, serverCall, new Metadata()); Mockito.when(serverCall.isReady()).thenReturn(true).thenReturn(false); Mockito.when(serverCall.isCancelled()).thenReturn(false).thenReturn(true); assertTrue(callObserver.get().isReady()); assertFalse(callObserver.get().isCancelled()); callListener.onReady(); callListener.onMessage(1); callListener.onCancel(); assertTrue(invokeCalled.get()); assertTrue(onReadyCalled.get()); assertTrue(onCancelCalled.get()); assertFalse(callObserver.get().isReady()); assertTrue(callObserver.get().isCancelled()); Mockito.verify(serverCall, times(2)).request(1); }
public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); static ServerCallHandler<ReqT, RespT> asyncUnaryCall(
      final UnaryMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncServerStreamingCall(
      final ServerStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncClientStreamingCall(
      final ClientStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      final BidiStreamingMethod<ReqT, RespT> method); static void asyncUnimplementedUnaryCall(MethodDescriptor<?, ?> methodDescriptor,
      StreamObserver<?> responseObserver); static StreamObserver<T> asyncUnimplementedStreamingCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver); }
ServerCalls { public static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall( final BidiStreamingMethod<ReqT, RespT> method) { return asyncStreamingRequestCall(method); } private  ServerCalls(); static ServerCallHandler<ReqT, RespT> asyncUnaryCall(
      final UnaryMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncServerStreamingCall(
      final ServerStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncClientStreamingCall(
      final ClientStreamingMethod<ReqT, RespT> method); static ServerCallHandler<ReqT, RespT> asyncBidiStreamingCall(
      final BidiStreamingMethod<ReqT, RespT> method); static void asyncUnimplementedUnaryCall(MethodDescriptor<?, ?> methodDescriptor,
      StreamObserver<?> responseObserver); static StreamObserver<T> asyncUnimplementedStreamingCall(
      MethodDescriptor<?, ?> methodDescriptor, StreamObserver<?> responseObserver);  }