assertEquals(3, map.values(new PredicateBuilder().getEntryObject().get("name").notEqual("aac")).size());
assertEquals(2, map.values(new PredicateBuilder().getEntryObject().get("index").notEqual(2)).size());
}
public static void doFunctionalSQLQueryTest(IMap imap) {
imap.put("1", new Employee("joe", 33, false, 14.56));
imap.put("2", new Employee("ali", 23, true, 15.00));
for (int i = 3; i < 103; i++) {
imap.put(String.valueOf(i), new Employee("name" + i, i % 60, ((i & 1) == 1), Double.valueOf(i)));
}
Set<Map.Entry> entries = imap.entrySet();
assertEquals(102, entries.size());
int itCount = 0;
for (Map.Entry entry : entries) {
Employee c = (Employee) entry.getValue();
itCount++;
}
assertEquals(102, itCount);
entries = imap.entrySet(new SqlPredicate("active=true and age=23"));
assertEquals(3, entries.size());
for (Map.Entry entry : entries) {
Employee c = (Employee) entry.getValue();
assertEquals(c.getAge(), 23);
assertTrue(c.isActive());
}
imap.remove("2");
entries = imap.entrySet(new SqlPredicate("active=true and age=23"));
assertEquals(2, entries.size());
for (Map.Entry entry : entries) {
Employee c = (Employee) entry.getValue();
assertEquals(c.getAge(), 23);
assertTrue(c.isActive());
}
entries = imap.entrySet(new SqlPredicate("age!=33"));
for (Map.Entry entry : entries) {
Employee c = (Employee) entry.getValue();
assertTrue(c.getAge() != 33);
}
entries = imap.entrySet(new SqlPredicate("active!=false"));
for (Map.Entry entry : entries) {
Employee c = (Employee) entry.getValue();
assertTrue(c.isActive());
}
}