@Test public void callReturnsAnEmptyBodyWhenTheStatusCodeIsNotOk() throws IOException { HttpResponse invalidResponse = response(500, "invalidType"); HttpClient httpClient = mock(HttpClient.class); when(httpClient.execute(any())).thenReturn(invalidResponse); HttpCaller instance = new HttpCaller(httpClient); ActualResultWithBody<TestClass> call = instance.call(new HttpRequest("GET", "http: assertThat(call.getBody().isPresent(), is(false)); }
@Override public ActualResult call(HttpRequest value) throws IOException { return executeRequest(value, response -> { LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : response.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } return new ActualResult( response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), headers ); }); }
HttpCaller implements nl.knaw.huygens.security.client.HttpCaller { @Override public ActualResult call(HttpRequest value) throws IOException { return executeRequest(value, response -> { LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : response.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } return new ActualResult( response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), headers ); }); } }
HttpCaller implements nl.knaw.huygens.security.client.HttpCaller { @Override public ActualResult call(HttpRequest value) throws IOException { return executeRequest(value, response -> { LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : response.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } return new ActualResult( response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), headers ); }); } HttpCaller(HttpClient httpClient); }
HttpCaller implements nl.knaw.huygens.security.client.HttpCaller { @Override public ActualResult call(HttpRequest value) throws IOException { return executeRequest(value, response -> { LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : response.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } return new ActualResult( response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), headers ); }); } HttpCaller(HttpClient httpClient); @Override ActualResult call(HttpRequest value); @Override ActualResultWithBody<T> call(HttpRequest value, Class<? extends T> clazz); }
HttpCaller implements nl.knaw.huygens.security.client.HttpCaller { @Override public ActualResult call(HttpRequest value) throws IOException { return executeRequest(value, response -> { LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : response.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } return new ActualResult( response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), headers ); }); } HttpCaller(HttpClient httpClient); @Override ActualResult call(HttpRequest value); @Override ActualResultWithBody<T> call(HttpRequest value, Class<? extends T> clazz);  }