### Question:
App { public String post(final String content) throws Exception { final var request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("X-Meta-Var", "FooBar") .POST(BodyPublishers.ofString(content)) .build(); final var client = HttpClient.newHttpClient(); return client.send(request, BodyHandlers.ofString()).body(); } App(final String url); String post(final String content);  }### Answer:
@Test public void testPost() throws Exception { try (final var server = new MockWebServer()) { server.enqueue(new MockResponse().setBody("world")); final var app = new App(server.url("/").url().toExternalForm()); assertEquals("world", app.post("hello")); assertEquals(1, server.getRequestCount()); final RecordedRequest request = server.takeRequest(); assertEquals("FooBar", request.getHeader("X-Meta-Var")); assertEquals("hello", request.getBody().readString(StandardCharsets.UTF_8)); } }