Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> 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<WireMockServer> stubSetup,
final Consumer<WireMockServer> requestExecutor) {
return executeWithStub(stubSetup, requestExecutor, new AllureRestAssured());
Expand Down
Loading