Search in sources :

Example 11 with AndPredicate

use of com.hazelcast.query.impl.predicates.AndPredicate in project hazelcast by hazelcast.

the class SqlPredicateTest method testAnd_whenBothPredicatesAnd.

@Test
public void testAnd_whenBothPredicatesAnd() {
    AndPredicate predicate1 = new AndPredicate(new SqlPredicate("a == 1"), new SqlPredicate("a == 2"));
    AndPredicate predicate2 = new AndPredicate(new SqlPredicate("a == 3"));
    AndPredicate concatenatedOr = SqlPredicate.flattenCompound(predicate1, predicate2, AndPredicate.class);
    assertEquals(3, concatenatedOr.getPredicates().length);
}
Also used : AndPredicate(com.hazelcast.query.impl.predicates.AndPredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) DateHelperTest(com.hazelcast.query.impl.DateHelperTest) Test(org.junit.Test)

Example 12 with AndPredicate

use of com.hazelcast.query.impl.predicates.AndPredicate in project hazelcast by hazelcast.

the class SqlPredicateTest method testFlattenOr_withOrAndPredicates.

// (OR (OR A B) (AND C D)) is flattened to (OR A B (AND C D))
@Test
public void testFlattenOr_withOrAndPredicates() {
    OrPredicate orPredicate = new OrPredicate(leftOfOr, rightOfOr);
    AndPredicate andPredicate = new AndPredicate(leftOfAnd, rightOfAnd);
    OrPredicate flattenedCompoundOr = SqlPredicate.flattenCompound(orPredicate, andPredicate, OrPredicate.class);
    assertSame(leftOfOr, flattenedCompoundOr.getPredicates()[0]);
    assertSame(rightOfOr, flattenedCompoundOr.getPredicates()[1]);
    assertSame(andPredicate, flattenedCompoundOr.getPredicates()[2]);
}
Also used : OrPredicate(com.hazelcast.query.impl.predicates.OrPredicate) AndPredicate(com.hazelcast.query.impl.predicates.AndPredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) DateHelperTest(com.hazelcast.query.impl.DateHelperTest) Test(org.junit.Test)

Aggregations

AndPredicate (com.hazelcast.query.impl.predicates.AndPredicate)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 DateHelperTest (com.hazelcast.query.impl.DateHelperTest)11 OrPredicate (com.hazelcast.query.impl.predicates.OrPredicate)7 TestUtil.toData (com.hazelcast.instance.TestUtil.toData)1 Data (com.hazelcast.nio.serialization.Data)1 EqualPredicate (com.hazelcast.query.impl.predicates.EqualPredicate)1 GreaterLessPredicate (com.hazelcast.query.impl.predicates.GreaterLessPredicate)1 RegexPredicate (com.hazelcast.query.impl.predicates.RegexPredicate)1