@Test public void getUnaryRequest() { MethodDescriptor<?, ?> getMethod = MethodDescriptor.<Void, Void>newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("service/method") .setIdempotent(true) .setSafe(true) .setRequestMarshaller(marshaller) .setResponseMarshaller(marshaller) .build(); stream = new OkHttpClientStream(getMethod, new Metadata(), frameWriter, transport, flowController, lock, MAX_MESSAGE_SIZE, INITIAL_WINDOW_SIZE, "localhost", "good-application", StatsTraceContext.NOOP, transportTracer, CallOptions.DEFAULT); stream.start(new BaseClientStreamListener()); verify(frameWriter, times(0)).synStream( eq(false), eq(false), eq(3), eq(0), headersCaptor.capture()); verify(transport, times(0)).streamReadyToStart(isA(OkHttpClientStream.class)); byte[] msg = "request".getBytes(Charset.forName("UTF-8")); stream.writeMessage(new ByteArrayInputStream(msg)); stream.halfClose(); verify(transport).streamReadyToStart(eq(stream)); stream.transportState().start(3); verify(frameWriter) .synStream(eq(true), eq(false), eq(3), eq(0), headersCaptor.capture()); assertThat(headersCaptor.getValue()).contains(Headers.METHOD_GET_HEADER); assertThat(headersCaptor.getValue()).contains( new Header(Header.TARGET_PATH, "/" + getMethod.getFullMethodName() + "?" + BaseEncoding.base64().encode(msg))); }
@Override protected TransportState transportState() { return state; }
OkHttpClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } }
OkHttpClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } OkHttpClientStream(
      MethodDescriptor<?, ?> method,
      Metadata headers,
      AsyncFrameWriter frameWriter,
      OkHttpClientTransport transport,
      OutboundFlowController outboundFlow,
      Object lock,
      int maxMessageSize,
      int initialWindowSize,
      String authority,
      String userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); }
OkHttpClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } OkHttpClientStream(
      MethodDescriptor<?, ?> method,
      Metadata headers,
      AsyncFrameWriter frameWriter,
      OkHttpClientTransport transport,
      OutboundFlowController outboundFlow,
      Object lock,
      int maxMessageSize,
      int initialWindowSize,
      String authority,
      String userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); MethodDescriptor.MethodType getType(); int id(); @Override void setAuthority(String authority); @Override Attributes getAttributes(); }
OkHttpClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } OkHttpClientStream(
      MethodDescriptor<?, ?> method,
      Metadata headers,
      AsyncFrameWriter frameWriter,
      OkHttpClientTransport transport,
      OutboundFlowController outboundFlow,
      Object lock,
      int maxMessageSize,
      int initialWindowSize,
      String authority,
      String userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); MethodDescriptor.MethodType getType(); int id(); @Override void setAuthority(String authority); @Override Attributes getAttributes(); static final int ABSENT_ID; }