NettyClientStream extends Http2ClientStream { @Override public Integer id() { return id; } NettyClientStream(MethodDescriptor<?, ?> method, Metadata headers, Channel channel,
      NettyClientHandler handler, int maxMessageSize, AsciiString authority, AsciiString scheme); @Override void setAuthority(String authority); @Override void start(ClientStreamListener listener); @Override void request(int numMessages); @Override Integer id(); void id(int id); void setHttp2Stream(Http2Stream http2Stream); @Nullable Http2Stream http2Stream();  }
@Test public void closeShouldSucceed() { stream().id(STREAM_ID); stream().halfClose(); assertTrue(stream().canReceive()); assertFalse(stream().canSend()); }
@Test public void cancelShouldSendCommand() { stream().id(STREAM_ID); stream().cancel(Status.CANCELLED); ArgumentCaptor<CancelClientStreamCommand> commandCaptor = ArgumentCaptor.forClass(CancelClientStreamCommand.class); verify(writeQueue).enqueue(commandCaptor.capture(), eq(true)); assertEquals(commandCaptor.getValue().reason(), Status.CANCELLED); }
@Test public void deadlineExceededCancelShouldSendCommand() { stream().id(STREAM_ID); stream().cancel(Status.DEADLINE_EXCEEDED); ArgumentCaptor<CancelClientStreamCommand> commandCaptor = ArgumentCaptor.forClass(CancelClientStreamCommand.class); verify(writeQueue).enqueue(commandCaptor.capture(), eq(true)); assertEquals(commandCaptor.getValue().reason(), Status.DEADLINE_EXCEEDED); }
@Test public void writeMessageShouldSendRequest() throws Exception { stream().id(STREAM_ID); byte[] msg = smallMessage(); stream.writeMessage(new ByteArrayInputStream(msg)); stream.flush(); verify(writeQueue).enqueue( eq(new SendGrpcFrameCommand(stream, messageFrame(MESSAGE), false)), any(ChannelPromise.class), eq(true)); }
@Test public void writeMessageShouldSendRequestUnknownLength() throws Exception { stream().id(STREAM_ID); byte[] msg = smallMessage(); stream.writeMessage(new BufferedInputStream(new ByteArrayInputStream(msg))); stream.flush(); verify(writeQueue).enqueue( eq(new SendGrpcFrameCommand(stream, messageFrame(MESSAGE).slice(0, 5), false)), any(ChannelPromise.class), eq(false)); verify(writeQueue).enqueue( eq(new SendGrpcFrameCommand(stream, messageFrame(MESSAGE).slice(5, 11), false)), any(ChannelPromise.class), eq(true)); }
@Test public void setStatusWithOkShouldCloseStream() { stream().id(STREAM_ID); stream().transportReportStatus(Status.OK, true, new Metadata()); verify(listener).closed(same(Status.OK), any(Metadata.class)); assertTrue(stream.isClosed()); }