### Question:
Fetcher { GetAccountResponse getAccount( final MultiValueMap<String, String> cookies ) throws InterruptedException { final ClientResponse clientResponse = get(ACCOUNT_PATH, cookies); final String body = MonoUtils.unwrap(clientResponse.bodyToMono(String.class), TIMEOUT); if (StringUtils.isEmpty(body)) { throw new RuntimeException("An empty body received"); } return GetAccountResponse.builder() .body(body) .cookies(CookieUtils.normalize(clientResponse.cookies())) .build(); } Fetcher(
        final WebClient.Builder webClientBuilder
    );   }### Answer:
@Test @SneakyThrows public void getAccountTest() { final MockResponse mockResponse = new MockResponse() .setBody("body") .setHeader(HttpHeaders.SET_COOKIE, "res=12345"); mockWebServer.enqueue(mockResponse); final MultiValueMap<String, String> requestCookies = new LinkedMultiValueMap<>(); requestCookies.set("req", "abc"); final MultiValueMap<String, String> responseCookies = new LinkedMultiValueMap<>(); responseCookies.set("res", "12345"); final Fetcher.GetAccountResponse expected = Fetcher.GetAccountResponse.builder() .body("body") .cookies(responseCookies) .build(); final Fetcher.GetAccountResponse actual = fetcher.getAccount(requestCookies); assertEquals(expected, actual); final RecordedRequest recordedRequest = mockWebServer.takeRequest(); assertEquals(1, mockWebServer.getRequestCount()); assertEquals(HttpMethod.GET.name(), recordedRequest.getMethod()); assertEquals(Fetcher.ACCOUNT_PATH, recordedRequest.getPath()); assertEquals("req=abc", recordedRequest.getHeader(HttpHeaders.COOKIE)); }
@Test @SneakyThrows public void getAccountTest_emptyBody() { expectedException.expect(RuntimeException.class); expectedException.expectMessage("An empty body received"); final MockResponse mockResponse = new MockResponse().setBody(""); mockWebServer.enqueue(mockResponse); final MultiValueMap<String, String> cookies = new LinkedMultiValueMap<>(); fetcher.getAccount(cookies); }