Search in sources :

Example 26 with Predicate

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

the class TestPredicateExpressionParser method testDoubleNot.

@Test
public void testDoubleNot() {
    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);
}
Also used : 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 27 with Predicate

use of com.linkedin.data.it.Predicate 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);
}
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 28 with Predicate

use of com.linkedin.data.it.Predicate 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 29 with Predicate

use of com.linkedin.data.it.Predicate 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 30 with Predicate

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

the class TestPredicateExpressionParser method testPredicate.

@Test
public void testPredicate() {
    final Predicate parsed = PredicateExpressionParser.parse("com.linkedin.data.it.AlwaysTruePredicate");
    Assert.assertEquals(parsed.getClass(), AlwaysTruePredicate.class);
}
Also used : 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

Predicate (com.linkedin.data.it.Predicate)33 Test (org.testng.annotations.Test)28 AlwaysFalsePredicate (com.linkedin.data.it.AlwaysFalsePredicate)26 AlwaysTruePredicate (com.linkedin.data.it.AlwaysTruePredicate)26 AndPredicate (com.linkedin.data.it.AndPredicate)26 NotPredicate (com.linkedin.data.it.NotPredicate)26 OrPredicate (com.linkedin.data.it.OrPredicate)26 DataSchema (com.linkedin.data.schema.DataSchema)4 NamedDataSchema (com.linkedin.data.schema.NamedDataSchema)4 SchemaParser (com.linkedin.data.schema.SchemaParser)4 DataMap (com.linkedin.data.DataMap)3 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)2 Schema (org.apache.avro.Schema)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 DataElement (com.linkedin.data.element.DataElement)1 ValidationOptions (com.linkedin.data.schema.validation.ValidationOptions)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1