use of com.linkedin.data.it.Predicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testOrAndOr.
@Test
public void testOrAndOr() {
final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate & com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate");
Assert.assertEquals(parsed.getClass(), OrPredicate.class);
final List<Predicate> orChildren = ((OrPredicate) parsed).getChildPredicates();
Assert.assertEquals(orChildren.get(0).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(orChildren.get(1).getClass(), AndPredicate.class);
Assert.assertEquals(orChildren.get(2).getClass(), AlwaysFalsePredicate.class);
final List<Predicate> andChildren = ((AndPredicate) orChildren.get(1)).getChildPredicates();
Assert.assertEquals(andChildren.get(0).getClass(), AlwaysFalsePredicate.class);
Assert.assertEquals(andChildren.get(1).getClass(), AlwaysTruePredicate.class);
}
use of com.linkedin.data.it.Predicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testDoubleNotParen.
@Test
public void testDoubleNotParen() {
final Predicate parsed = PredicateExpressionParser.parse("(!(!(com.linkedin.data.it.AlwaysTruePredicate)))");
Assert.assertEquals(parsed.getClass(), NotPredicate.class);
final Predicate intermediate1 = ((NotPredicate) parsed).getChildPredicate();
Assert.assertEquals(intermediate1.getClass(), NotPredicate.class);
final Predicate intermediate2 = ((NotPredicate) intermediate1).getChildPredicate();
Assert.assertEquals(intermediate2.getClass(), AlwaysTruePredicate.class);
}
use of com.linkedin.data.it.Predicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testNotAnd.
@Test
public void testNotAnd() {
final Predicate parsed = PredicateExpressionParser.parse("!com.linkedin.data.it.AlwaysTruePredicate & com.linkedin.data.it.AlwaysFalsePredicate");
Assert.assertEquals(parsed.getClass(), AndPredicate.class);
final List<Predicate> andChildren = ((AndPredicate) parsed).getChildPredicates();
Assert.assertEquals(andChildren.get(0).getClass(), NotPredicate.class);
Assert.assertEquals(andChildren.get(1).getClass(), AlwaysFalsePredicate.class);
final Predicate notChild = ((NotPredicate) andChildren.get(0)).getChildPredicate();
Assert.assertEquals(notChild.getClass(), AlwaysTruePredicate.class);
}
Aggregations