HttpCall extends Call.Base<V> { @Override public HttpCall<V> clone() { return new HttpCall<>(httpClient, request, bodyConverter, name); } HttpCall(WebClient httpClient, RequestSupplier request, BodyConverter<V> bodyConverter,
    String name); @Override HttpCall<V> clone(); @Override String toString(); final RequestSupplier request; }
@Test void cloned() throws Exception { server.enqueue(SUCCESS_RESPONSE); Call<?> call = http.newCall(REQUEST, (parser, contentString) -> null, "test"); call.execute(); assertThatThrownBy(call::execute).isInstanceOf(IllegalStateException.class); server.enqueue(SUCCESS_RESPONSE); call.clone().execute(); }
@Test void executionException_message() { Map<AggregatedHttpResponse, String> responseToMessage = new LinkedHashMap<>(); responseToMessage.put(AggregatedHttpResponse.of( ResponseHeaders.of(HttpStatus.FORBIDDEN), HttpData.ofUtf8( "{\"Message\":\"User: anonymous is not authorized to perform: es:ESHttpGet\"}") ), "User: anonymous is not authorized to perform: es:ESHttpGet"); responseToMessage.put(AggregatedHttpResponse.of( ResponseHeaders.of(HttpStatus.FORBIDDEN) ), "response for / failed: 403 Forbidden"); responseToMessage.put(AggregatedHttpResponse.of( ResponseHeaders.of(HttpStatus.BAD_GATEWAY), HttpData.ofUtf8("Message: sleet") ), "response for / failed: Message: sleet"); Call<?> call = http.newCall(REQUEST, NULL, "test"); for (Map.Entry<AggregatedHttpResponse, String> entry : responseToMessage.entrySet()) { server.enqueue(entry.getKey()); call = call.clone(); assertThatThrownBy(call::execute) .isInstanceOf(RuntimeException.class) .hasMessage(entry.getValue()); } }