### Question:
DefaultWhenHttpClient implements WhenHttpClient { @Override public Promise<Buffer> body(HttpClientResponse response) { Deferred<Buffer> d = when.defer(); Promise<Buffer> p = d.getPromise(); response.bodyHandler(d::resolve).resume(); if (response instanceof HttpClientResponseContext) { HttpClientRequestContext context = ((HttpClientResponseContext) response).getContext(); if (context.shouldCloseClient()) { p = p.then(body -> { if (context.shouldCloseClient()) { context.getClient().close(); context.setCloseClient(false); } return when.resolve(body); }); } } return p; } @Inject  DefaultWhenHttpClient(Vertx vertx, When when); @Override Promise<HttpClientResponse> request(HttpMethod method, int port, String host, String requestURI); @Override Promise<HttpClientResponse> request(HttpMethod method, int port, String host, String requestURI, RequestOptions options); @Override Promise<HttpClientResponse> request(HttpMethod method, String host, String requestURI); @Override Promise<HttpClientResponse> request(HttpMethod method, String host, String requestURI, RequestOptions options); @Override Promise<HttpClientResponse> request(HttpMethod method, String requestURI); @Override Promise<HttpClientResponse> request(HttpMethod method, String requestURI, RequestOptions options); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, int port, String host, String requestURI); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, int port, String host, String requestURI, RequestOptions options); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, String host, String requestURI); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, String host, String requestURI, RequestOptions options); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, String requestURI); @Override Promise<HttpClientResponseAndBody> requestAndReadBody(HttpMethod method, String requestURI, RequestOptions options); @Override Promise<HttpClientResponse> requestAbs(HttpMethod method, String absoluteURI); @Override Promise<HttpClientResponse> requestAbs(HttpMethod method, String absoluteURI, RequestOptions options); @Override Promise<HttpClientResponseAndBody> requestAbsAndReadBody(HttpMethod method, String absoluteURI); @Override Promise<HttpClientResponseAndBody> requestAbsAndReadBody(HttpMethod method, String absoluteURI, RequestOptions options); @Override Promise<Buffer> body(HttpClientResponse response);  }### Answer:
@Test public void testBody() throws Exception { when(response.bodyHandler(any())).thenReturn(response); Done<Buffer> done = new Done<>(); whenHttpClient.body(response).then(done.onFulfilled, done.onRejected); verify(response).resume(); verify(response).bodyHandler(bodyHandlerCaptor.capture()); bodyHandlerCaptor.getValue().handle(body); done.assertFulfilled(); }