test: Normalize line breaks in JSON payloads before comparing
@@ -47,12 +47,14 @@ public final class WireMockStubs {
}
public static void verifyRequestContains(RequestPatternBuilder builder, String maybeJson) {
+ maybeJson = maybeJson.trim().replaceAll("\\r\\n", "\\n");
verify(builder.withHeader("Content-Type", containing("application/x-www-form-urlencoded"))
.withHeader("Accept", equalTo("*/*"))
.withRequestBody(maybeJson.startsWith("{") ? containing(maybeJson.substring(1, maybeJson.length() - 1)) : containing(maybeJson)));
}
public static void verifyJsonRequestContains(RequestPatternBuilder builder, String maybeJson) {
+ maybeJson = maybeJson.trim().replaceAll("\\r\\n", "\\n");
verify(builder.withHeader("Content-Type", containing("application/json"))
.withHeader("Accept", or(equalTo("*/*"), equalTo("application/json")))
.withRequestBody(maybeJson.startsWith("{") ? containing(maybeJson.substring(1, maybeJson.length() - 1)) : containing(maybeJson)));
