Search in sources :

Example 6 with OrPredicate

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

the class SqlPredicateTest method testOr_whenRightPredicateOr.

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

Example 7 with OrPredicate

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

the class SqlPredicateTest method testFlattenOr_withTwoAndPredicates.

// (OR (AND A B) (AND C D)) is not flattened
@Test
public void testFlattenOr_withTwoAndPredicates() {
    AndPredicate andLeft = new AndPredicate(leftOfOr, rightOfOr);
    AndPredicate andRight = new AndPredicate(leftOfAnd, rightOfAnd);
    OrPredicate flattenedCompoundOr = SqlPredicate.flattenCompound(andLeft, andRight, OrPredicate.class);
    assertSame(andLeft, flattenedCompoundOr.getPredicates()[0]);
    assertSame(andRight, flattenedCompoundOr.getPredicates()[1]);
}
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)

Example 8 with OrPredicate

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

the class SqlPredicateTest method testFlattenAnd_withOrAndPredicates.

// (AND (OR A B) (AND C D)) is flattened to (AND (OR A B) C D)
@Test
public void testFlattenAnd_withOrAndPredicates() {
    OrPredicate orPredicate = new OrPredicate(leftOfOr, rightOfOr);
    AndPredicate andPredicate = new AndPredicate(leftOfAnd, rightOfAnd);
    AndPredicate flattenedCompoundAnd = SqlPredicate.flattenCompound(orPredicate, andPredicate, AndPredicate.class);
    assertSame(orPredicate, flattenedCompoundAnd.getPredicates()[0]);
    assertSame(leftOfAnd, flattenedCompoundAnd.getPredicates()[1]);
    assertSame(rightOfAnd, flattenedCompoundAnd.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)

Example 9 with OrPredicate

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

the class SqlPredicateTest method testFlattenAnd_withAndORPredicates.

// (AND (AND A B) (OR C D)) is flattened to (AND A B (OR C D))
@Test
public void testFlattenAnd_withAndORPredicates() {
    OrPredicate orPredicate = new OrPredicate(leftOfOr, rightOfOr);
    AndPredicate andPredicate = new AndPredicate(leftOfAnd, rightOfAnd);
    AndPredicate flattenedCompoundAnd = SqlPredicate.flattenCompound(andPredicate, orPredicate, AndPredicate.class);
    assertSame(leftOfAnd, flattenedCompoundAnd.getPredicates()[0]);
    assertSame(rightOfAnd, flattenedCompoundAnd.getPredicates()[1]);
    assertSame(orPredicate, flattenedCompoundAnd.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)

Example 10 with OrPredicate

use of com.hazelcast.query.impl.predicates.OrPredicate 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

DateHelperTest (com.hazelcast.query.impl.DateHelperTest)10 OrPredicate (com.hazelcast.query.impl.predicates.OrPredicate)10 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 AndPredicate (com.hazelcast.query.impl.predicates.AndPredicate)6