@Test public void testPost() throws Exception { MockResponse mockResponse = new MockResponse() .setBody(TEST_RESPONSE_BODY) .setResponseCode(StatusCode.OK.getCode()); server.enqueue(mockResponse); RxHttpClient client = RxOkHttpClient.newBuilder() .build(); Request request = new Request.Builder() .url(server.url("/").toString()) .post() .body(RequestBody.create(TEST_REQUEST_BODY)) .build(); Response response = client.execute(request).toBlocking().first(); Assertions.assertThat(response.isSuccessful()).isTrue(); String actualResponseBody = response.getBody().get(String.class); Assertions.assertThat(actualResponseBody).isEqualTo(TEST_RESPONSE_BODY); RecordedRequest recordedRequest = server.takeRequest(1, TimeUnit.MILLISECONDS); Assertions.assertThat(recordedRequest).isNotNull(); String actualRequestBody = recordedRequest.getBody().readUtf8(); Assertions.assertThat(actualRequestBody).isEqualTo(TEST_REQUEST_BODY); }
@Override public Observable<Response> post(String url, Object entity) { Request request = new Request.Builder() .url(url) .post() .body(RequestBody.create(entity)) .build(); return execute(request); }
RxOkHttpClient implements RxHttpClient { @Override public Observable<Response> post(String url, Object entity) { Request request = new Request.Builder() .url(url) .post() .body(RequestBody.create(entity)) .build(); return execute(request); } }
RxOkHttpClient implements RxHttpClient { @Override public Observable<Response> post(String url, Object entity) { Request request = new Request.Builder() .url(url) .post() .body(RequestBody.create(entity)) .build(); return execute(request); } RxOkHttpClient(Builder builder); }
RxOkHttpClient implements RxHttpClient { @Override public Observable<Response> post(String url, Object entity) { Request request = new Request.Builder() .url(url) .post() .body(RequestBody.create(entity)) .build(); return execute(request); } RxOkHttpClient(Builder builder); @Override Observable<Response> execute(Request request); @Override Observable<Response> get(String url); @Override Observable<Response> head(String url); @Override Observable<Response> post(String url, Object entity); @Override Observable<Response> delete(String url); @Override Observable<Response> delete(String url, Object entity); @Override Observable<Response> put(String url, Object entity); @Override Observable<Response> patch(String url, Object entity); SSLContext sslContext(); X509TrustManager trustManager(); List<Interceptor> interceptors(); static Builder newBuilder(); static Builder newBuilder(RxOkHttpClient rxOkHttpClient); }
RxOkHttpClient implements RxHttpClient { @Override public Observable<Response> post(String url, Object entity) { Request request = new Request.Builder() .url(url) .post() .body(RequestBody.create(entity)) .build(); return execute(request); } RxOkHttpClient(Builder builder); @Override Observable<Response> execute(Request request); @Override Observable<Response> get(String url); @Override Observable<Response> head(String url); @Override Observable<Response> post(String url, Object entity); @Override Observable<Response> delete(String url); @Override Observable<Response> delete(String url, Object entity); @Override Observable<Response> put(String url, Object entity); @Override Observable<Response> patch(String url, Object entity); SSLContext sslContext(); X509TrustManager trustManager(); List<Interceptor> interceptors(); static Builder newBuilder(); static Builder newBuilder(RxOkHttpClient rxOkHttpClient);  }