use of com.linkedin.data.it.OrPredicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testOrAnd.
@Test
public void testOrAnd() {
final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate & com.linkedin.data.it.AlwaysTruePredicate");
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);
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.OrPredicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testOrParenAnd.
@Test
public void testOrParenAnd() {
final Predicate parsed = PredicateExpressionParser.parse("(com.linkedin.data.it.AlwaysTruePredicate | 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(), OrPredicate.class);
Assert.assertEquals(andChildren.get(1).getClass(), AlwaysFalsePredicate.class);
final List<Predicate> orChildren = ((OrPredicate) andChildren.get(0)).getChildPredicates();
Assert.assertEquals(orChildren.get(0).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(orChildren.get(1).getClass(), AlwaysTruePredicate.class);
}
use of com.linkedin.data.it.OrPredicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testOr.
@Test
public void testOr() {
final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate");
Assert.assertEquals(parsed.getClass(), OrPredicate.class);
final List<Predicate> children = ((OrPredicate) parsed).getChildPredicates();
Assert.assertEquals(children.get(0).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(children.get(1).getClass(), AlwaysFalsePredicate.class);
}
use of com.linkedin.data.it.OrPredicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testOrOr.
@Test
public void testOrOr() {
final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate");
Assert.assertEquals(parsed.getClass(), OrPredicate.class);
final List<Predicate> children = ((OrPredicate) parsed).getChildPredicates();
Assert.assertEquals(children.get(0).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(children.get(1).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(children.get(2).getClass(), AlwaysFalsePredicate.class);
}
use of com.linkedin.data.it.OrPredicate in project rest.li by linkedin.
the class TestPredicateExpressionParser method testNotOrParenAnd.
@Test
public void testNotOrParenAnd() {
final Predicate parsed = PredicateExpressionParser.parse("!(com.linkedin.data.it.AlwaysTruePredicate | 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(), NotPredicate.class);
final Predicate notChild1 = ((NotPredicate) andChildren.get(0)).getChildPredicate();
Assert.assertEquals(notChild1.getClass(), OrPredicate.class);
final Predicate notChild2 = ((NotPredicate) andChildren.get(1)).getChildPredicate();
Assert.assertEquals(notChild2.getClass(), AlwaysFalsePredicate.class);
final List<Predicate> orChildren = ((OrPredicate) notChild1).getChildPredicates();
Assert.assertEquals(orChildren.get(0).getClass(), AlwaysTruePredicate.class);
Assert.assertEquals(orChildren.get(1).getClass(), AlwaysTruePredicate.class);
}
Aggregations