Search in sources :

Example 1 with OrPredicate

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

the class TestPredicateExpressionParser method testNotParenOr.

@Test
public void testNotParenOr() {
    final Predicate parsed = PredicateExpressionParser.parse("!(com.linkedin.data.it.AlwaysTruePredicate | com.linkedin.data.it.AlwaysFalsePredicate)");
    Assert.assertEquals(parsed.getClass(), NotPredicate.class);
    final Predicate intermediate = ((NotPredicate) parsed).getChildPredicate();
    Assert.assertEquals(intermediate.getClass(), OrPredicate.class);
    final List<Predicate> children = ((OrPredicate) intermediate).getChildPredicates();
    Assert.assertEquals(children.get(0).getClass(), AlwaysTruePredicate.class);
    Assert.assertEquals(children.get(1).getClass(), AlwaysFalsePredicate.class);
}
Also used : OrPredicate(com.linkedin.data.it.OrPredicate) 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)

Example 2 with OrPredicate

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

the class TestPredicateExpressionParser method testNotAndParenOr.

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

Example 3 with OrPredicate

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

the class TestPredicateExpressionParser method testAndParenOr.

@Test
public void testAndParenOr() {
    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(), AlwaysTruePredicate.class);
    Assert.assertEquals(andChildren.get(1).getClass(), OrPredicate.class);
    final List<Predicate> orChildren = ((OrPredicate) andChildren.get(1)).getChildPredicates();
    Assert.assertEquals(orChildren.get(0).getClass(), AlwaysTruePredicate.class);
    Assert.assertEquals(orChildren.get(1).getClass(), AlwaysFalsePredicate.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 4 with OrPredicate

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

the class TestPredicateExpressionParser method testOrNot.

@Test
public void testOrNot() {
    final Predicate parsed = PredicateExpressionParser.parse("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(), NotPredicate.class);
    final Predicate notChild = ((NotPredicate) orChildren.get(1)).getChildPredicate();
    Assert.assertEquals(notChild.getClass(), AlwaysFalsePredicate.class);
}
Also used : OrPredicate(com.linkedin.data.it.OrPredicate) 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)

Example 5 with OrPredicate

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

the class TestPredicateExpressionParser method testNotNotOr.

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