@Test public void cancelStream() { ArgumentCaptor<BidirectionalStream.Callback> callbackCaptor = ArgumentCaptor.forClass(BidirectionalStream.Callback.class); verify(factory) .newBidirectionalStreamBuilder( isA(String.class), callbackCaptor.capture(), isA(Executor.class)); BidirectionalStream.Callback callback = callbackCaptor.getValue(); clientStream.cancel(Status.DEADLINE_EXCEEDED); verify(transport, times(0)).finishStream(eq(clientStream), isA(Status.class)); callback.onCanceled(cronetStream, null); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(transport, times(1)).finishStream(eq(clientStream), statusCaptor.capture()); Status status = statusCaptor.getValue(); assertEquals(Status.DEADLINE_EXCEEDED.getCode(), status.getCode()); }
private void finishStream(Status status) { transport.finishStream(this, status); }
CronetClientStream extends AbstractClientStream { private void finishStream(Status status) { transport.finishStream(this, status); } }
CronetClientStream extends AbstractClientStream { private void finishStream(Status status) { transport.finishStream(this, status); } CronetClientStream(
      final String url,
      @Nullable String userAgent,
      Executor executor,
      final Metadata headers,
      CronetClientTransport transport,
      Runnable startCallback,
      Object lock,
      int maxMessageSize,
      boolean alwaysUsePut,
      MethodDescriptor<?, ?> method,
      StatsTraceContext statsTraceCtx,
      CallOptions callOptions,
      TransportTracer transportTracer); }
CronetClientStream extends AbstractClientStream { private void finishStream(Status status) { transport.finishStream(this, status); } CronetClientStream(
      final String url,
      @Nullable String userAgent,
      Executor executor,
      final Metadata headers,
      CronetClientTransport transport,
      Runnable startCallback,
      Object lock,
      int maxMessageSize,
      boolean alwaysUsePut,
      MethodDescriptor<?, ?> method,
      StatsTraceContext statsTraceCtx,
      CallOptions callOptions,
      TransportTracer transportTracer); @Override void setAuthority(String authority); @Override Attributes getAttributes(); }
CronetClientStream extends AbstractClientStream { private void finishStream(Status status) { transport.finishStream(this, status); } CronetClientStream(
      final String url,
      @Nullable String userAgent,
      Executor executor,
      final Metadata headers,
      CronetClientTransport transport,
      Runnable startCallback,
      Object lock,
      int maxMessageSize,
      boolean alwaysUsePut,
      MethodDescriptor<?, ?> method,
      StatsTraceContext statsTraceCtx,
      CallOptions callOptions,
      TransportTracer transportTracer); @Override void setAuthority(String authority); @Override Attributes getAttributes();  }