Search in sources :

Example 11 with AndPredicate

use of com.linkedin.data.it.AndPredicate in project rest.li by linkedin.

the class TestPredicateExpressionParser method testAndOr.

@Test
public void testAndOr() {
    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> orChildren = ((OrPredicate) parsed).getChildPredicates();
    Assert.assertEquals(orChildren.get(0).getClass(), AndPredicate.class);
    Assert.assertEquals(orChildren.get(1).getClass(), AlwaysFalsePredicate.class);
    final List<Predicate> andChildren = ((AndPredicate) orChildren.get(0)).getChildPredicates();
    Assert.assertEquals(andChildren.get(0).getClass(), AlwaysTruePredicate.class);
    Assert.assertEquals(andChildren.get(1).getClass(), AlwaysTruePredicate.class);
}
Also used : OrPredicate(com.linkedin.data.it.OrPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) NotPredicate(com.linkedin.data.it.NotPredicate) AlwaysTruePredicate(com.linkedin.data.it.AlwaysTruePredicate) AlwaysFalsePredicate(com.linkedin.data.it.AlwaysFalsePredicate) OrPredicate(com.linkedin.data.it.OrPredicate) Predicate(com.linkedin.data.it.Predicate) Test(org.testng.annotations.Test)

Example 12 with AndPredicate

use of com.linkedin.data.it.AndPredicate in project rest.li by linkedin.

the class TestPredicateExpressionParser method testAndOrAnd.

@Test
public void testAndOrAnd() {
    final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate & com.linkedin.data.it.AlwaysFalsePredicate | 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(), AndPredicate.class);
    Assert.assertEquals(orChildren.get(1).getClass(), AndPredicate.class);
    final List<Predicate> andChildren0 = ((AndPredicate) orChildren.get(0)).getChildPredicates();
    Assert.assertEquals(andChildren0.get(0).getClass(), AlwaysTruePredicate.class);
    Assert.assertEquals(andChildren0.get(1).getClass(), AlwaysFalsePredicate.class);
    final List<Predicate> andChildren1 = ((AndPredicate) orChildren.get(1)).getChildPredicates();
    Assert.assertEquals(andChildren1.get(0).getClass(), AlwaysFalsePredicate.class);
    Assert.assertEquals(andChildren1.get(1).getClass(), AlwaysTruePredicate.class);
}
Also used : OrPredicate(com.linkedin.data.it.OrPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) NotPredicate(com.linkedin.data.it.NotPredicate) AlwaysTruePredicate(com.linkedin.data.it.AlwaysTruePredicate) AlwaysFalsePredicate(com.linkedin.data.it.AlwaysFalsePredicate) OrPredicate(com.linkedin.data.it.OrPredicate) Predicate(com.linkedin.data.it.Predicate) Test(org.testng.annotations.Test)

Example 13 with AndPredicate

use of com.linkedin.data.it.AndPredicate 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);
}
Also used : OrPredicate(com.linkedin.data.it.OrPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) NotPredicate(com.linkedin.data.it.NotPredicate) AlwaysTruePredicate(com.linkedin.data.it.AlwaysTruePredicate) AlwaysFalsePredicate(com.linkedin.data.it.AlwaysFalsePredicate) OrPredicate(com.linkedin.data.it.OrPredicate) Predicate(com.linkedin.data.it.Predicate) Test(org.testng.annotations.Test)

Example 14 with AndPredicate

use of com.linkedin.data.it.AndPredicate 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);
}
Also used : AndPredicate(com.linkedin.data.it.AndPredicate) NotPredicate(com.linkedin.data.it.NotPredicate) AndPredicate(com.linkedin.data.it.AndPredicate) NotPredicate(com.linkedin.data.it.NotPredicate) AlwaysTruePredicate(com.linkedin.data.it.AlwaysTruePredicate) AlwaysFalsePredicate(com.linkedin.data.it.AlwaysFalsePredicate) OrPredicate(com.linkedin.data.it.OrPredicate) Predicate(com.linkedin.data.it.Predicate) Test(org.testng.annotations.Test)

Aggregations

AlwaysFalsePredicate (com.linkedin.data.it.AlwaysFalsePredicate)14 AlwaysTruePredicate (com.linkedin.data.it.AlwaysTruePredicate)14 AndPredicate (com.linkedin.data.it.AndPredicate)14 NotPredicate (com.linkedin.data.it.NotPredicate)14 OrPredicate (com.linkedin.data.it.OrPredicate)14 Predicate (com.linkedin.data.it.Predicate)14 Test (org.testng.annotations.Test)14