Search in sources :

Example 1 with CacheEventDataImpl

use of com.hazelcast.cache.impl.CacheEventDataImpl in project hazelcast by hazelcast.

the class EventQueuePluginTest method testSampleRunnable.

@Test
public void testSampleRunnable() {
    Address caller = new Address();
    Data data = mock(Data.class);
    EntryEventData mapEventAdded = new EntryEventData("source", "mapName", caller, data, data, data, ADDED.getType());
    EntryEventData mapEventUpdated = new EntryEventData("source", "mapName", caller, data, data, data, UPDATED.getType());
    EntryEventData mapEventRemoved = new EntryEventData("source", "mapName", caller, data, data, data, REMOVED.getType());
    assertSampleRunnable("IMap 'mapName' ADDED", mapEventAdded, MapService.SERVICE_NAME);
    assertSampleRunnable("IMap 'mapName' UPDATED", mapEventUpdated, MapService.SERVICE_NAME);
    assertSampleRunnable("IMap 'mapName' REMOVED", mapEventRemoved, MapService.SERVICE_NAME);
    CacheEventData cacheEventCreated = new CacheEventDataImpl("cacheName", CacheEventType.CREATED, data, data, data, true);
    CacheEventData cacheEventUpdated = new CacheEventDataImpl("cacheName", CacheEventType.UPDATED, data, data, data, true);
    CacheEventData cacheEventRemoved = new CacheEventDataImpl("cacheName", CacheEventType.REMOVED, data, data, data, true);
    CacheEventSet CacheEventSetCreated = new CacheEventSet(CacheEventType.CREATED, singleton(cacheEventCreated), 1);
    CacheEventSet CacheEventSetUpdated = new CacheEventSet(CacheEventType.UPDATED, singleton(cacheEventUpdated), 1);
    CacheEventSet cacheEventSetRemoved = new CacheEventSet(CacheEventType.REMOVED, singleton(cacheEventRemoved), 1);
    assertSampleRunnable("ICache 'cacheName' CREATED", CacheEventSetCreated, CacheService.SERVICE_NAME);
    assertSampleRunnable("ICache 'cacheName' UPDATED", CacheEventSetUpdated, CacheService.SERVICE_NAME);
    assertSampleRunnable("ICache 'cacheName' REMOVED", cacheEventSetRemoved, CacheService.SERVICE_NAME);
    List<CacheEventData> cacheEventData = asList(cacheEventCreated, cacheEventUpdated, cacheEventRemoved);
    Set<CacheEventData> cacheEvents = new HashSet<CacheEventData>(cacheEventData);
    CacheEventSet cacheEventSetAll = new CacheEventSet(CacheEventType.EXPIRED, cacheEvents, 1);
    assertCacheEventSet(cacheEventSetAll, "ICache 'cacheName' CREATED", "ICache 'cacheName' UPDATED", "ICache 'cacheName' REMOVED");
    QueueEvent queueEventAdded = new QueueEvent("queueName", data, ItemEventType.ADDED, caller);
    QueueEvent queueEventRemoved = new QueueEvent("queueName", data, ItemEventType.REMOVED, caller);
    assertSampleRunnable("IQueue 'queueName' ADDED", queueEventAdded, QueueService.SERVICE_NAME);
    assertSampleRunnable("IQueue 'queueName' REMOVED", queueEventRemoved, QueueService.SERVICE_NAME);
    CollectionEvent setEventAdded = new CollectionEvent("setName", data, ItemEventType.ADDED, caller);
    CollectionEvent setEventRemoved = new CollectionEvent("setName", data, ItemEventType.REMOVED, caller);
    assertSampleRunnable("ISet 'setName' ADDED", setEventAdded, SetService.SERVICE_NAME);
    assertSampleRunnable("ISet 'setName' REMOVED", setEventRemoved, SetService.SERVICE_NAME);
    CollectionEvent listEventAdded = new CollectionEvent("listName", data, ItemEventType.ADDED, caller);
    CollectionEvent listEventRemoved = new CollectionEvent("listName", data, ItemEventType.REMOVED, caller);
    assertSampleRunnable("IList 'listName' ADDED", listEventAdded, ListService.SERVICE_NAME);
    assertSampleRunnable("IList 'listName' REMOVED", listEventRemoved, ListService.SERVICE_NAME);
    assertSampleRunnable("Object", new Object(), LongRegisterService.SERVICE_NAME);
    assertSampleRunnable(new TestEvent(), TestEvent.class.getName());
}
Also used : Address(com.hazelcast.cluster.Address) CacheEventSet(com.hazelcast.cache.impl.CacheEventSet) CollectionEvent(com.hazelcast.collection.impl.collection.CollectionEvent) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) CacheEventData(com.hazelcast.cache.impl.CacheEventData) Data(com.hazelcast.internal.serialization.Data) CacheEventDataImpl(com.hazelcast.cache.impl.CacheEventDataImpl) CacheEventData(com.hazelcast.cache.impl.CacheEventData) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) QueueEvent(com.hazelcast.collection.impl.queue.QueueEvent) HashSet(java.util.HashSet) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CacheEventData (com.hazelcast.cache.impl.CacheEventData)1 CacheEventDataImpl (com.hazelcast.cache.impl.CacheEventDataImpl)1 CacheEventSet (com.hazelcast.cache.impl.CacheEventSet)1 Address (com.hazelcast.cluster.Address)1 CollectionEvent (com.hazelcast.collection.impl.collection.CollectionEvent)1 QueueEvent (com.hazelcast.collection.impl.queue.QueueEvent)1 Data (com.hazelcast.internal.serialization.Data)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1