@Test public void requestThrowing_WithBinding_ExceptionMapping() throws Exception { for (Map.Entry<Integer, Class> entry : responseCodesToExceptions().entrySet()) { try { server.enqueue(new MockResponse().setResponseCode(entry.getKey())); buildResource().requestThrowing("POST", baseUrl(), buildOptions(), String.class); fail("expected exception for " + entry.getValue()); } catch (NakadiException e) { assertEquals(entry.getValue(), e.getClass()); assertEquals(Problem.T1000_TYPE, e.problem().type()); } } }
@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);  }