Search in sources :

Example 6 with AndPredicate

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

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

the class SqlPredicateTest method testAnd_whenNoPredicateAnd.

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

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

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

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

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