Consider empty arrays as existent in JsonPath assertions

Prior to this commit, a JsonPath assertion that a path expression
evaluated to an array in JsonPathExpectationsHelper (and therefore
indirectly in JsonPathResultMatchers in Spring MVC Test) would
incorrectly fail if the array was present in the JSON content but empty.

This commit fixes this issue by removing the "not empty" check for
arrays and lists.

Issue: SPR-13320
This commit is contained in:
Sam Brannen
2015-08-14 17:20:07 +02:00
parent 8afea1bc78
commit 5a05cdbedb
3 changed files with 30 additions and 14 deletions

View File

@@ -238,9 +238,6 @@ public class JsonPathExpectationsHelper {
Object value = evaluateJsonPath(content);
String reason = "No value for JSON path \"" + this.expression + "\"";
assertTrue(reason, value != null);
if (List.class.isInstance(value)) {
assertTrue(reason, !((List<?>) value).isEmpty());
}
return value;
}