Search in sources :

Example 11 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class BetweenVisitorTest method whenPredicateIsNotGreaterLessPredicate_thenIsNotUsedToBuildBetween.

@Test
public void whenPredicateIsNotGreaterLessPredicate_thenIsNotUsedToBuildBetween() {
    Predicate left = equal("attribute", 5);
    Predicate right = lessEqual("attribute", 6);
    Predicate and = and(left, right);
    Predicate result = visitor.visit((AndPredicate) and, mockIndexes);
    assertSame(and, result);
}
Also used : Predicate(com.hazelcast.query.Predicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class BetweenVisitorTest method whenOnlyOneSideFound_thenReturnOriginalPredicate.

@Test
public void whenOnlyOneSideFound_thenReturnOriginalPredicate() {
    Predicate p1 = greaterEqual("attribute1", 5);
    Predicate p2 = lessEqual("attribute2", 6);
    Predicate and = and(p1, p2);
    Predicate result = visitor.visit((AndPredicate) and, mockIndexes);
    assertSame(and, result);
}
Also used : Predicate(com.hazelcast.query.Predicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class BetweenVisitorTest method whenPredicatesOutsideTheRangeFromRightExist_thenEliminateThem.

@Test
public void whenPredicatesOutsideTheRangeFromRightExist_thenEliminateThem() {
    //(age >= 5 and age <= 6 and age < 10)  -->  (age between 5 6)
    Predicate left = greaterEqual("attribute", 5);
    Predicate right = lessEqual("attribute", 6);
    Predicate other = lessEqual("attribute", 10);
    Predicate and = and(left, right, other);
    Predicate result = visitor.visit((AndPredicate) and, mockIndexes);
    assertBetweenPredicate(result, 5, 6);
}
Also used : Predicate(com.hazelcast.query.Predicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 14 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class BetweenVisitorTest method whenNoConverterExist_thenReturnOriginalPredicate.

@Test
public void whenNoConverterExist_thenReturnOriginalPredicate() {
    disableConverter();
    Predicate left = greaterEqual("attribute", 5);
    Predicate right = lessEqual("attribute", 6);
    Predicate and = and(left, right);
    Predicate result = visitor.visit((AndPredicate) and, mockIndexes);
    assertSame(and, result);
}
Also used : Predicate(com.hazelcast.query.Predicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 15 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class BetweenVisitorTest method whenSideAreOverlapping_thenReturnFalsePredicate.

@Test
public void whenSideAreOverlapping_thenReturnFalsePredicate() {
    Predicate p1 = greaterEqual("attribute1", 5);
    Predicate p2 = lessEqual("attribute1", 4);
    Predicate and = and(p1, p2);
    Predicate result = visitor.visit((AndPredicate) and, mockIndexes);
    assertEquals(FalsePredicate.INSTANCE, result);
}
Also used : Predicate(com.hazelcast.query.Predicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Predicate (com.hazelcast.query.Predicate)248 Test (org.junit.Test)165 QuickTest (com.hazelcast.test.annotation.QuickTest)159 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)105 HazelcastInstance (com.hazelcast.core.HazelcastInstance)38 MapListener (com.hazelcast.map.listener.MapListener)17 ParallelTest (com.hazelcast.test.annotation.ParallelTest)17 EntryListener (com.hazelcast.core.EntryListener)16 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)15 ArrayList (java.util.ArrayList)15 EntryObject (com.hazelcast.query.PredicateBuilder.EntryObject)14 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)14 Value (com.hazelcast.query.SampleTestObjects.Value)10 SqlPredicate (com.hazelcast.query.SqlPredicate)10 Config (com.hazelcast.config.Config)9 PredicateTestUtils.createMockVisitablePredicate (com.hazelcast.query.impl.predicates.PredicateTestUtils.createMockVisitablePredicate)9 EntryEvent (com.hazelcast.core.EntryEvent)8 Data (com.hazelcast.internal.serialization.Data)8 MapListenerAdapter (com.hazelcast.map.impl.MapListenerAdapter)8 Indexes (com.hazelcast.query.impl.Indexes)8