Added NPE guard when there are no bytes returned

This commit is contained in:
Marcin Grzejszczak
2019-11-18 14:20:00 +01:00
parent 703e0f2b15
commit 732b7d401c

View File

@@ -57,10 +57,13 @@ public abstract class WireMockVerifyHelper<T, S extends WireMockVerifyHelper<T,
public void configure(T result) { public void configure(T result) {
Map<String, Object> configuration = getConfiguration(result); Map<String, Object> configuration = getConfiguration(result);
String actual = new String(getRequestBodyContent(result), byte[] requestBodyContent = getRequestBodyContent(result);
Charset.forName("UTF-8")); if (requestBodyContent != null) {
for (JsonPath jsonPath : this.jsonPaths.values()) { String actual = new String(requestBodyContent,
new JsonPathValue(jsonPath, actual).assertHasValue(Object.class, "an object"); Charset.forName("UTF-8"));
for (JsonPath jsonPath : this.jsonPaths.values()) {
new JsonPathValue(jsonPath, actual).assertHasValue(Object.class, "an object");
}
} }
configuration.put("contract.jsonPaths", this.jsonPaths.keySet()); configuration.put("contract.jsonPaths", this.jsonPaths.keySet());
if (this.contentType != null) { if (this.contentType != null) {