@Test
public void writeForm() {
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.set("name 1", "value 1");
body.add("name 2", "value 2+1");
body.add("name 2", "value 2+2");
body.add("name 3", null);
MockServerHttpResponse response = new MockServerHttpResponse(this.bufferFactory);
this.writer.write(Mono.just(body), null, MediaType.APPLICATION_FORM_URLENCODED, response, null).block();
String expected = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3";
StepVerifier.create(response.getBody())
.consumeNextWith(stringConsumer(
expected))
.expectComplete()
.verify();
HttpHeaders headers = response.getHeaders();
assertEquals("application/x-www-form-urlencoded;charset=UTF-8", headers.getContentType().toString());
assertEquals(expected.length(), headers.getContentLength());
}