@Test public void a_lt_filter_can_be_serialized() { String filter = filter(where("a").lt(1)).toString(); String parsed = parse("[?(@['a'] < 1)]").toString(); assertThat(filter).isEqualTo(parsed); }
@Test public void lt_filters_evaluates() throws Exception { Map<String, Object> check = new HashMap<String, Object>(); check.put("foo", 10.5D); check.put("foo_null", null); //assertTrue(filter(where("foo").lt(12D)).apply(createPredicateContext(check))); assertFalse(filter(where("foo").lt(null)).apply(createPredicateContext(check))); //assertFalse(filter(where("foo").lt(5D)).apply(createPredicateContext(check))); //assertFalse(filter(where("foo_null").lt(5D)).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))); }