Search in sources :

Example 1 with OrPredicate

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

the class SqlPredicateTest method testOr_whenNoPredicateOr.

@Test
public void testOr_whenNoPredicateOr() {
    TruePredicate predicate1 = new TruePredicate();
    TruePredicate predicate2 = new TruePredicate();
    OrPredicate concatenatedOr = SqlPredicate.flattenCompound(predicate1, predicate2, OrPredicate.class);
    assertEquals(2, concatenatedOr.getPredicates().length);
    assertSame(predicate1, concatenatedOr.getPredicates()[0]);
    assertSame(predicate2, concatenatedOr.getPredicates()[1]);
}
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 2 with OrPredicate

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

the class SqlPredicateTest method testOr_whenLeftPredicateOr.

@Test
public void testOr_whenLeftPredicateOr() {
    OrPredicate predicate1 = new OrPredicate(new SqlPredicate("a == 1"), new SqlPredicate("a == 2"));
    TruePredicate predicate2 = new TruePredicate();
    OrPredicate concatenatedOr = SqlPredicate.flattenCompound(predicate1, predicate2, OrPredicate.class);
    assertEquals(3, concatenatedOr.getPredicates().length);
    assertInstanceOf(SqlPredicate.class, concatenatedOr.getPredicates()[0]);
    assertInstanceOf(SqlPredicate.class, concatenatedOr.getPredicates()[1]);
    assertSame(predicate2, 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 3 with OrPredicate

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

the class SqlPredicateTest method testFlattenOr_withAndOrPredicates.

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

Example 4 with OrPredicate

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

the class SqlPredicateTest method testFlattenAnd_withTwoOrPredicates.

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

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

the class SqlPredicateTest method testOr_whenBothPredicatesOr.

@Test
public void testOr_whenBothPredicatesOr() {
    OrPredicate predicate1 = new OrPredicate(new SqlPredicate("a == 1"), new SqlPredicate("a == 2"));
    OrPredicate predicate2 = new OrPredicate(new SqlPredicate("a == 3"));
    OrPredicate concatenatedOr = SqlPredicate.flattenCompound(predicate1, predicate2, OrPredicate.class);
    assertEquals(3, concatenatedOr.getPredicates().length);
}
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)

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