Example #1
0
  @Test
  public void issue_129() throws Exception {

    final Map<String, Integer> match = new HashMap<String, Integer>();
    match.put("a", 1);
    match.put("b", 2);

    Map<String, Integer> noMatch = new HashMap<String, Integer>();
    noMatch.put("a", -1);
    noMatch.put("b", -2);

    Filter orig = filter(where("a").eq(1).and("b").eq(2));

    String filterAsString = orig.toString();

    Filter parsed = Filter.parse(filterAsString);

    assertThat(orig.apply(createPredicateContext(match))).isTrue();
    assertThat(parsed.apply(createPredicateContext(match))).isTrue();
    assertThat(orig.apply(createPredicateContext(noMatch))).isFalse();
    assertThat(parsed.apply(createPredicateContext(noMatch))).isFalse();
  }