use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.
the class NestedPredicateWithExtractorTest method singleAttributeQuery_predicates.
@Test
public void singleAttributeQuery_predicates() throws Exception {
// GIVEN
map.put(1, new Body("body1", new Limb("hand")));
map.put(2, new Body("body2", new Limb("leg")));
// WHEN
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("name").equal("body1");
Collection<Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new Body[values.size()])[0].getName());
assertEquals(2 + 1, bodyExtractorExecutions);
assertEquals(0, limbExtractorExecutions);
}
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);
}
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);
}
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);
}
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);
}
Aggregations