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]);
}
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]);
}
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]);
}
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]);
}
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);
}
Aggregations