|
36 | 36 |
|
37 | 37 | import java.nio.charset.StandardCharsets; |
38 | 38 | import java.util.Collection; |
| 39 | +import java.util.LinkedHashMap; |
39 | 40 | import java.util.List; |
40 | 41 | import java.util.Map; |
41 | 42 | import java.util.function.Consumer; |
@@ -301,6 +302,33 @@ void shouldRenderListValuedFormParams() { |
301 | 302 | .contains("data=[a, b]"); |
302 | 303 | } |
303 | 304 |
|
| 305 | + @Test |
| 306 | + void shouldNotFailForNullValuedFormParamsMap() { |
| 307 | + final ResponseDefinitionBuilder responseBuilder = WireMock.aResponse() |
| 308 | + .withStatus(200) |
| 309 | + .withBody("some body"); |
| 310 | + |
| 311 | + final Map<String, Object> formParams = new LinkedHashMap<>(); |
| 312 | + formParams.put("param1", "value1"); |
| 313 | + formParams.put("param2", null); |
| 314 | + |
| 315 | + final AllureResults results = executeWithStub( |
| 316 | + server -> WireMock.stubFor(WireMock.post(WireMock.urlPathEqualTo("/hello")) |
| 317 | + .willReturn(responseBuilder)), |
| 318 | + server -> RestAssured.given() |
| 319 | + .contentType(ContentType.URLENC) |
| 320 | + .formParams(formParams) |
| 321 | + .post(server.url("/hello")).then().statusCode(200) |
| 322 | + ); |
| 323 | + |
| 324 | + assertThat(results.getTestResults() |
| 325 | + .stream() |
| 326 | + .map(TestResult::getAttachments) |
| 327 | + .flatMap(Collection::stream) |
| 328 | + .map(Attachment::getName)) |
| 329 | + .containsExactly("Request", "HTTP/1.1 200 OK"); |
| 330 | + } |
| 331 | + |
304 | 332 | protected final AllureResults executeWithStub(final Consumer<WireMockServer> stubSetup, |
305 | 333 | final Consumer<WireMockServer> requestExecutor) { |
306 | 334 | return executeWithStub(stubSetup, requestExecutor, new AllureRestAssured()); |
|
0 commit comments