Defaults { public static Function<Exception, RuntimeException> passthrough() { return e -> { if (e instanceof RuntimeException) { return (RuntimeException) e; } else { return new TDPException(CommonErrorCodes.UNEXPECTED_SERVICE_EXCEPTION, e, build().put("message", e.getMessage())); } }; } private  Defaults(); static Function<Exception, RuntimeException> passthrough(); static BiFunction<HttpRequestBase, HttpResponse, T> asNull(); static BiFunction<HttpRequestBase, HttpResponse, String> asString(); static BiFunction<HttpRequestBase, HttpResponse, String> emptyString(); static BiFunction<HttpRequestBase, HttpResponse, InputStream> emptyStream(); static BiFunction<HttpRequestBase, HttpResponse, InputStream> pipeStream(); static BiFunction<HttpRequestBase, HttpResponse, T> convertResponse(ObjectMapper mapper,
            Class<T> clazz); static BiFunction<HttpRequestBase, HttpResponse, T> convertResponse(ObjectMapper mapper,
            TypeReference<T> typeReference); static BiFunction<HttpRequestBase, HttpResponse, T> convertResponse(ObjectMapper mapper,
            TypeReference<T> typeReference, Function<Exception, T> errorHandler); static BiFunction<HttpRequestBase, HttpResponse, JsonNode> toJson(ObjectMapper mapper); static BiFunction<HttpRequestBase, HttpResponse, S> iterate(Class<T> clazz, ObjectMapper mapper,
            Function<Iterator<T>, S> convert); static ResponseEntity<String> getResponseEntity(HttpStatus status, HttpResponse response);  }
@Test public void shoudPassthrough() throws Exception { final RuntimeException runtimeException = new RuntimeException(); final Exception exception = new Exception(); try { Defaults.passthrough().apply(runtimeException); } catch (Exception e) { assertEquals(runtimeException, e); } try { Defaults.passthrough().apply(exception); } catch (TDPException e) { assertEquals(CommonErrorCodes.UNEXPECTED_EXCEPTION, e.getCode()); } }