@Test public void a_gt_filter_can_be_serialized() { String filter = filter(where("a").gt(1)).toString(); String parsed = parse("[?(@['a'] > 1)]").toString(); assertThat(filter).isEqualTo(parsed); }
@Test public void gt_filters_evaluates() throws Exception { final Map<String, Object> check = new HashMap<String, Object>(); check.put("foo", 12.5D); check.put("foo_null", null); assertTrue(filter(where("foo").gt(12D)).apply(createPredicateContext(check))); assertFalse(filter(where("foo").gt(null)).apply(createPredicateContext(check))); assertFalse(filter(where("foo").gt(20D)).apply(createPredicateContext(check))); assertFalse(filter(where("foo_null").gt(20D)).apply(createPredicateContext(check))); }
@Test public void filters_can_be_combined() throws Exception { Map<String, Object> check = new HashMap<String, Object>(); check.put("string", "foo"); check.put("string_null", null); check.put("int", 10); check.put("long", 1L); check.put("double", 1.12D); Filter shouldMarch = filter(where("string").is("foo").and("int").lt(11)); Filter shouldNotMarch = filter(where("string").is("foo").and("int").gt(11)); assertTrue(shouldMarch.apply(createPredicateContext(check))); assertFalse(shouldNotMarch.apply(createPredicateContext(check))); }