Search in sources :

Example 1 with MyPortableElement

use of com.hazelcast.client.standalone.model.MyPortableElement in project hazelcast by hazelcast.

the class ClientMapStandaloneTest method testRemoveAllWithPredicate_DoesNotDeserializeValues.

@Test
public void testRemoveAllWithPredicate_DoesNotDeserializeValues() {
    IMap<Integer, MyPortableElement> map = createMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, new MyPortableElement(i));
    }
    Predicate<Integer, MyPortableElement> predicate = in("id", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    map.removeAll(predicate);
    for (int i = 0; i < 10; i++) {
        MyPortableElement entry = map.get(i);
        assertNull(entry);
    }
    for (int i = 10; i < 100; i++) {
        MyPortableElement entry = map.get(i);
        assertNotNull(entry);
    }
}
Also used : MyPortableElement(com.hazelcast.client.standalone.model.MyPortableElement) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with MyPortableElement

use of com.hazelcast.client.standalone.model.MyPortableElement in project hazelcast by hazelcast.

the class ClientMapStandaloneTest method testPortable_query_with_index.

@Test
public void testPortable_query_with_index() {
    IMap<Integer, MyPortableElement> map = createMap();
    for (int i = 0; i < 100; i++) {
        MyPortableElement element = new MyPortableElement(i);
        map.put(i, element);
    }
    map.addIndex(IndexType.HASH, "id");
    Predicate predicate = or(equal("id", 0), equal("id", 1));
    Collection values = map.values(predicate);
    assertEquals(2, values.size());
}
Also used : MyPortableElement(com.hazelcast.client.standalone.model.MyPortableElement) Collection(java.util.Collection) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with MyPortableElement

use of com.hazelcast.client.standalone.model.MyPortableElement in project hazelcast by hazelcast.

the class ClientMapStandaloneTest method testPortable_withEntryListenerWithPredicate.

@Test
public void testPortable_withEntryListenerWithPredicate() {
    int key = 1;
    int id = 1;
    IMap<Integer, MyPortableElement> map = createMap();
    Predicate<Integer, MyPortableElement> predicate = equal("id", id);
    MyPortableElement element = new MyPortableElement(id);
    final CountDownLatch eventLatch = new CountDownLatch(1);
    map.addEntryListener(new EntryAdapter<Integer, MyPortableElement>() {

        @Override
        public void onEntryEvent(EntryEvent<Integer, MyPortableElement> event) {
            eventLatch.countDown();
        }
    }, predicate, true);
    map.put(key, element);
    assertOpenEventually(eventLatch);
    Collection values = map.values(Predicates.lessThan("date", new Date().getTime()));
    assertEquals(values.iterator().next(), element);
}
Also used : MyPortableElement(com.hazelcast.client.standalone.model.MyPortableElement) Collection(java.util.Collection) CountDownLatch(java.util.concurrent.CountDownLatch) Date(java.util.Date) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MyPortableElement (com.hazelcast.client.standalone.model.MyPortableElement)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 Collection (java.util.Collection)2 Predicate (com.hazelcast.query.Predicate)1 Date (java.util.Date)1 CountDownLatch (java.util.concurrent.CountDownLatch)1