Skip to content

Commit 8624b33

Browse files
turing85christophd
authored andcommitted
#26: Null values should not be sent to the /run endpoint.
To achieve this, we: - set "".setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL)" on the class-level objectMapper, and - use the class-level objectMapper instead of a new ObjectMapper to construct the request body
1 parent 6c6c0a2 commit 8624b33

File tree

1 file changed

+3
-2
lines changed
  • citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin

1 file changed

+3
-2
lines changed

citrus-remote-maven-plugin/src/main/java/org/citrusframework/remote/plugin/RunTestMojo.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.citrusframework.remote.plugin;
1818

19+
import com.fasterxml.jackson.annotation.JsonInclude;
1920
import com.fasterxml.jackson.databind.ObjectMapper;
2021
import org.apache.hc.core5.http.*;
2122
import org.apache.hc.core5.http.io.entity.EntityUtils;
@@ -71,7 +72,7 @@ public class RunTestMojo extends AbstractCitrusRemoteMojo {
7172
/**
7273
* Object mapper for JSON response to object conversion.
7374
*/
74-
private final ObjectMapper objectMapper = new ObjectMapper();
75+
private final ObjectMapper objectMapper = new ObjectMapper().setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
7576

7677
private static String parseResultToStringRepresentation(TestResult result) {
7778
if (result.isSkipped()) {
@@ -175,7 +176,7 @@ private void runTests(TestRunConfiguration runConfiguration) throws MojoExecutio
175176

176177
requestBuilder.addHeader(new BasicHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON.getMimeType()));
177178

178-
StringEntity body = new StringEntity(new ObjectMapper().writeValueAsString(runConfiguration), ContentType.APPLICATION_JSON);
179+
StringEntity body = new StringEntity(objectMapper.writeValueAsString(runConfiguration), ContentType.APPLICATION_JSON);
179180
requestBuilder.setEntity(body);
180181

181182
try (var response = getHttpClient().executeOpen(null, requestBuilder.build(), null)) {

0 commit comments

Comments
 (0)