|
|
|
@ -9,6 +9,7 @@ import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
import com.jayway.jsonpath.BaseTest; |
|
|
|
|
import com.jayway.jsonpath.Criteria; |
|
|
|
|
import com.jayway.jsonpath.DocumentContext; |
|
|
|
|
import com.jayway.jsonpath.Filter; |
|
|
|
|
import com.jayway.jsonpath.JsonPath; |
|
|
|
|
|
|
|
|
@ -19,9 +20,11 @@ public class JsonReaderTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
Filter feq = Filter.filter(Criteria.where("category").eq("reference")); |
|
|
|
|
Filter fne = Filter.filter(Criteria.where("category").ne("reference")); |
|
|
|
|
|
|
|
|
|
DocumentContext JsonDoc = JsonPath.parse(JSON_DOCUMENT); |
|
|
|
|
|
|
|
|
|
List<String> eq = JsonPath.parse(JSON_DOCUMENT).read("$.store.book[?].category", feq); |
|
|
|
|
List<String> ne = JsonPath.parse(JSON_DOCUMENT).read("$.store.book[?].category", fne); |
|
|
|
|
List<String> eq = JsonDoc.read("$.store.book[?].category", feq); |
|
|
|
|
List<String> ne = JsonDoc.read("$.store.book[?].category", fne); |
|
|
|
|
|
|
|
|
|
Assertions.assertThat(eq).contains("reference"); |
|
|
|
|
Assertions.assertThat(ne).doesNotContain("reference"); |
|
|
|
|