diff --git a/json-path/src/test/java/com/jayway/jsonpath/internal/function/Issue628.java b/json-path/src/test/java/com/jayway/jsonpath/internal/function/Issue628.java index f990ab11..9f2a567f 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/internal/function/Issue628.java +++ b/json-path/src/test/java/com/jayway/jsonpath/internal/function/Issue628.java @@ -3,18 +3,39 @@ package com.jayway.jsonpath.internal.function; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Option; +import com.jayway.jsonpath.Predicate; import org.junit.Test; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import static org.junit.Assert.assertNull; public class Issue628 { @Test - public void nonexistant_property_returns_null_when_configured() { + public void empty_property_returns_null_when_configured() { String document = "{}"; Configuration config = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build(); String nonExistentPath = "$.doesNotExist"; assertNull(JsonPath.read(config.jsonProvider().parse(document), nonExistentPath)); } + + @Test + public void empty_array_can_be_filtered(){ + Map doc = new HashMap(); + + Predicate customFilter = new Predicate() { + @Override + public boolean apply(PredicateContext ctx) { + return 1 == (Integer)ctx.item(); + } + }; + + List res = JsonPath.read(doc, "$.items[?]", customFilter); + + assertNull(res); + } } \ No newline at end of file