### Question:
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);  }### Answer:
@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)); }
@Test public void callReturnsABodyWhenTheStatusCodeIsOk() throws IOException { TestClass testClass = new TestClass(); testClass.test = "value"; HttpResponse invalidResponse = response(200, new ObjectMapper().writeValueAsString(testClass)); 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(true)); assertThat(call.getBody().get().test, is("value")); }