@Test public void requestThrowingBody() throws Exception { OkHttpResource r = buildResource(); ResourceOptions options = buildOptions(); server.enqueue(new MockResponse().setResponseCode(200)); Subscription subscription = buildSubscription(); r.requestThrowing("POST", "http: () -> json.toJsonBytes(subscription)); RecordedRequest request = server.takeRequest(); assertEquals("POST /subscriptions HTTP/1.1", request.getRequestLine()); assertEquals("application/json; charset=utf8", request.getHeaders().get("Content-Type")); assertEquals(NakadiClient.USER_AGENT, request.getHeaders().get("User-Agent")); assertTrue(request.getHeaders().get("X-Flow-Id") != null); Subscription fromJson = json.fromJson(request.getBody().readUtf8(), Subscription.class); assertEquals(subscription, fromJson); }
@Override public Response requestThrowing(String method, String url, ResourceOptions options) throws NakadiException { return maybeComposeRetryPolicy( Observable.defer( () -> Observable.just(requestThrowingInner(method, url, options)))).blockingFirst(); }
OkHttpResource implements Resource { @Override public Response requestThrowing(String method, String url, ResourceOptions options) throws NakadiException { return maybeComposeRetryPolicy( Observable.defer( () -> Observable.just(requestThrowingInner(method, url, options)))).blockingFirst(); } }
OkHttpResource implements Resource { @Override public Response requestThrowing(String method, String url, ResourceOptions options) throws NakadiException { return maybeComposeRetryPolicy( Observable.defer( () -> Observable.just(requestThrowingInner(method, url, options)))).blockingFirst(); } OkHttpResource(OkHttpClient okHttpClient, JsonSupport jsonSupport, MetricCollector collector); }
OkHttpResource implements Resource { @Override public Response requestThrowing(String method, String url, ResourceOptions options) throws NakadiException { return maybeComposeRetryPolicy( Observable.defer( () -> Observable.just(requestThrowingInner(method, url, options)))).blockingFirst(); } OkHttpResource(OkHttpClient okHttpClient, JsonSupport jsonSupport, MetricCollector collector); OkHttpResource connectTimeout(long timeout, TimeUnit unit); OkHttpResource readTimeout(long timeout, TimeUnit unit); @Override Resource writeTimeout(long timeout, TimeUnit unit); OkHttpResource retryPolicy(RetryPolicy retryPolicy); @Override Response request(String method, String url, ResourceOptions options); @Override Response requestThrowing(String method, String url, ResourceOptions options); @Override Response requestThrowing(String method, String url, ResourceOptions options,
      ContentSupplier body); @Override Response postEventsThrowing(String url, ResourceOptions options, ContentSupplier body); @Override Res requestThrowing(String method, String url, ResourceOptions options,
      Class<Res> res); @Override Res requestThrowing(String method, String url, ResourceOptions options,
      ContentSupplier body, Class<Res> res); }
OkHttpResource implements Resource { @Override public Response requestThrowing(String method, String url, ResourceOptions options) throws NakadiException { return maybeComposeRetryPolicy( Observable.defer( () -> Observable.just(requestThrowingInner(method, url, options)))).blockingFirst(); } OkHttpResource(OkHttpClient okHttpClient, JsonSupport jsonSupport, MetricCollector collector); OkHttpResource connectTimeout(long timeout, TimeUnit unit); OkHttpResource readTimeout(long timeout, TimeUnit unit); @Override Resource writeTimeout(long timeout, TimeUnit unit); OkHttpResource retryPolicy(RetryPolicy retryPolicy); @Override Response request(String method, String url, ResourceOptions options); @Override Response requestThrowing(String method, String url, ResourceOptions options); @Override Response requestThrowing(String method, String url, ResourceOptions options,
      ContentSupplier body); @Override Response postEventsThrowing(String url, ResourceOptions options, ContentSupplier body); @Override Res requestThrowing(String method, String url, ResourceOptions options,
      Class<Res> res); @Override Res requestThrowing(String method, String url, ResourceOptions options,
      ContentSupplier body, Class<Res> res);  }