SendHttpRequest implements HttpFunction { @Override public void service(HttpRequest request, HttpResponse response) throws IOException, InterruptedException { String url = "http: var getRequest = java.net.http.HttpRequest.newBuilder().uri(URI.create(url)).GET().build(); var getResponse = client.send(getRequest, BodyHandlers.ofString()); var writer = new PrintWriter(response.getWriter()); writer.printf("Received code '%s' from url '%s'.", getResponse.statusCode(), url); }  @Override void service(HttpRequest request, HttpResponse response);  }
@Test public void sendHttpRequestTest() throws IOException, InterruptedException { new SendHttpRequest().service(request, response); writerOut.flush(); assertThat(responseOut.toString()).contains("Received code "); }