diff --git a/allure-rest-assured/src/test/java/io/qameta/allure/restassured/AllureRestAssuredTest.java b/allure-rest-assured/src/test/java/io/qameta/allure/restassured/AllureRestAssuredTest.java index 2210b7dc..c35cef0d 100644 --- a/allure-rest-assured/src/test/java/io/qameta/allure/restassured/AllureRestAssuredTest.java +++ b/allure-rest-assured/src/test/java/io/qameta/allure/restassured/AllureRestAssuredTest.java @@ -36,6 +36,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; @@ -301,6 +302,33 @@ void shouldRenderListValuedFormParams() { .contains("data=[a, b]"); } + @Test + void shouldNotFailForNullValuedFormParamsMap() { + final ResponseDefinitionBuilder responseBuilder = WireMock.aResponse() + .withStatus(200) + .withBody("some body"); + + final Map formParams = new LinkedHashMap<>(); + formParams.put("param1", "value1"); + formParams.put("param2", null); + + final AllureResults results = executeWithStub( + server -> WireMock.stubFor(WireMock.post(WireMock.urlPathEqualTo("/hello")) + .willReturn(responseBuilder)), + server -> RestAssured.given() + .contentType(ContentType.URLENC) + .formParams(formParams) + .post(server.url("/hello")).then().statusCode(200) + ); + + assertThat(results.getTestResults() + .stream() + .map(TestResult::getAttachments) + .flatMap(Collection::stream) + .map(Attachment::getName)) + .containsExactly("Request", "HTTP/1.1 200 OK"); + } + protected final AllureResults executeWithStub(final Consumer stubSetup, final Consumer requestExecutor) { return executeWithStub(stubSetup, requestExecutor, new AllureRestAssured());