JAVA-20277 GitHub Issue: Regarding article Introduction to JsonPath (#13939)

This commit is contained in:
anuragkumawat 2023-05-10 23:17:17 +05:30 committed by GitHub
parent 761eecbcd6
commit 386e3b2816
1 changed files with 12 additions and 0 deletions

View File

@ -1,9 +1,11 @@
package com.baeldung.jsonpath.introduction;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.Filter;
import org.junit.Test;
import java.io.InputStream;
@ -98,4 +100,14 @@ public class ServiceIntegrationTest {
assertEquals("Spectre", title);
}
@Test
public void givenJsonPathWithFilterPredicate_whenReadingRootNode_thenCorrect() {
Filter expensiveFilter = Filter.filter(Criteria.where("director")
.contains("Sam Mendes"));
List<Map<String, Object>> predicate = JsonPath.parse(jsonString)
.read("$[?]['director']", expensiveFilter);
assertEquals(predicate.size(), 2);
}
}