### Question:
Fetcher { @VisibleForTesting ClientResponse post( final String path, final MultiValueMap<String, ?> formData, final MultiValueMap<String, String> cookies ) throws InterruptedException { final ClientResponse clientResponse = MonoUtils.unwrap( webClient.post() .uri(path) .header(HttpHeaders.USER_AGENT, USER_AGENT) .bodyValue(formData) .cookies(builder -> builder.addAll(cookies)) .exchange(), TIMEOUT); patchBrokenCookies(clientResponse); return Objects.requireNonNull(clientResponse); } Fetcher(
        final WebClient.Builder webClientBuilder
    );   }### Answer:
@Test @SneakyThrows @SuppressWarnings({"unchecked", "UnassignedFluxMonoInstance"}) public void postTest() { final String path = "/foobar"; final MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.set("foo", "1"); final MultiValueMap<String, String> cookies = new LinkedMultiValueMap<>(); cookies.set("bar", "2"); final WebClient.RequestBodyUriSpec requestBodyUriSpec = mock(WebClient.RequestBodyUriSpec.class); final WebClient.RequestHeadersSpec requestHeadersSpec = mock(WebClient.RequestHeadersSpec.class); final Mono<ClientResponse> clientResponseMono = mock(Mono.class); final ClientResponse clientResponse = mock(ClientResponse.class); when(webClient.post()).thenReturn(requestBodyUriSpec); when(requestBodyUriSpec.uri(path)).thenReturn(requestBodyUriSpec); when(requestBodyUriSpec.header(HttpHeaders.USER_AGENT, USER_AGENT)).thenReturn(requestBodyUriSpec); when(requestBodyUriSpec.bodyValue(formData)).thenReturn(requestHeadersSpec); when(requestHeadersSpec.cookies(any())).thenReturn(requestHeadersSpec); when(requestHeadersSpec.exchange()).thenReturn(clientResponseMono); when(clientResponseMono.block(TIMEOUT)).thenReturn(clientResponse); final ClientResponse actual = fetcher.post(path, formData, cookies); assertSame(clientResponse, actual); final ArgumentCaptor<Consumer<MultiValueMap<String, String>>> consumerCaptor = ArgumentCaptor.forClass(Consumer.class); verify(webClient).post(); verify(requestBodyUriSpec).uri(path); verify(requestBodyUriSpec).header(HttpHeaders.USER_AGENT, USER_AGENT); verify(requestBodyUriSpec).bodyValue(formData); verify(requestHeadersSpec).cookies(consumerCaptor.capture()); verify(requestHeadersSpec).exchange(); verify(clientResponseMono).block(TIMEOUT); final Consumer<MultiValueMap<String, String>> consumer = consumerCaptor.getValue(); final MultiValueMap<String, String> builder = new LinkedMultiValueMap<>(); consumer.accept(builder); assertEquals(cookies, builder); }