Kalle Stenflo
10 years ago
13 changed files with 90 additions and 29 deletions
@ -0,0 +1,29 @@ |
|||||||
|
package com.jayway.jsonpath; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static com.jayway.jsonpath.JsonPath.using; |
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
|
||||||
|
public class PredicateTest extends BaseTest { |
||||||
|
|
||||||
|
private static ReadContext reader = using(GSON_CONFIGURATION).parse(JSON_DOCUMENT); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void predicates_filters_can_be_applied() { |
||||||
|
|
||||||
|
Predicate booksWithISBN = new Predicate() { |
||||||
|
@Override |
||||||
|
public boolean apply(PredicateContext ctx) { |
||||||
|
return ctx.item(Map.class).containsKey("isbn"); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
assertThat(reader.read("$.store.book[?].isbn", List.class, booksWithISBN)).containsOnly("0-395-19395-8", "0-553-21311-3"); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue