use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class PredicatesTest method testCriteriaAPI.
@Test
public void testCriteriaAPI() {
Object value = new Employee(12, "abc-123-xvz", 34, true, 10D);
EntryObject e = new PredicateBuilder().getEntryObject();
EntryObject e2 = e.get("age");
Predicate predicate = e2.greaterEqual(29).and(e2.lessEqual(36));
assertTrue(predicate.apply(createEntry("1", value)));
e = new PredicateBuilder().getEntryObject();
assertTrue(e.get("id").equal(12).apply(createEntry("1", value)));
}
use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateVersionedPortablesTest method singleAttributeQuery_versionedProtables_predicates.
@Test
public void singleAttributeQuery_versionedProtables_predicates() throws Exception {
// GIVEN
map.put(1, new NestedPredicateVersionedPortablesTest.Body("body1", new NestedPredicateVersionedPortablesTest.Limb("hand")));
map.put(2, new NestedPredicateVersionedPortablesTest.Body("body2", new NestedPredicateVersionedPortablesTest.Limb("leg")));
// WHEN
EntryObject e = new PredicateBuilder().getEntryObject();
Predicate predicate = e.get("limb.name").equal("hand");
Collection<NestedPredicateVersionedPortablesTest.Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body1", values.toArray(new NestedPredicateVersionedPortablesTest.Body[values.size()])[0].getName());
}
use of com.hazelcast.query.EntryObject in project hazelcast by hazelcast.
the class NestedPredicateWithExtractorTest method nestedAttributeQuery_predicates.
@Test
public void nestedAttributeQuery_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("limbname").equal("leg");
Collection<Body> values = map.values(predicate);
// THEN
assertEquals(1, values.size());
assertEquals("body2", values.toArray(new Body[values.size()])[0].getName());
assertEquals(0, bodyExtractorExecutions);
assertEquals(2 + 1, limbExtractorExecutions);
}
Aggregations