Search in sources :

Example 1 with DataAwareEntryEventConstructor

use of com.hazelcast.test.starter.constructor.DataAwareEntryEventConstructor in project hazelcast by hazelcast.

the class DataAwareEntryEventConstructorTest method testConstructor.

@Test
public void testConstructor() {
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    String key = "key";
    String newValue = "newValue";
    String oldValue = "oldValue";
    String mergingValue = "mergingValue";
    Member from = mock(Member.class);
    int eventType = EntryEventType.MERGED.getType();
    String source = UuidUtil.newUnsecureUuidString();
    Data dataKey = serializationService.toData(key);
    Data dataNewValue = serializationService.toData(newValue);
    Data dataOldValue = serializationService.toData(oldValue);
    Data dataMergingValue = serializationService.toData(mergingValue);
    DataAwareEntryEvent dataAwareEntryEvent = new DataAwareEntryEvent(from, eventType, source, dataKey, dataNewValue, dataOldValue, dataMergingValue, serializationService);
    DataAwareEntryEventConstructor constructor = new DataAwareEntryEventConstructor(DataAwareEntryEvent.class);
    DataAwareEntryEvent clonedDataAwareEntryEvent = (DataAwareEntryEvent) constructor.createNew(dataAwareEntryEvent);
    assertEquals(dataAwareEntryEvent.getName(), clonedDataAwareEntryEvent.getName());
    assertEquals(dataAwareEntryEvent.getMember(), clonedDataAwareEntryEvent.getMember());
    assertEquals(dataAwareEntryEvent.getEventType(), clonedDataAwareEntryEvent.getEventType());
    assertEquals(dataAwareEntryEvent.getSource(), clonedDataAwareEntryEvent.getSource());
    assertEquals(dataAwareEntryEvent.getKey(), clonedDataAwareEntryEvent.getKey());
    assertEquals(dataAwareEntryEvent.getKeyData(), clonedDataAwareEntryEvent.getKeyData());
    assertEquals(dataAwareEntryEvent.getValue(), clonedDataAwareEntryEvent.getValue());
    assertEquals(dataAwareEntryEvent.getNewValueData(), clonedDataAwareEntryEvent.getNewValueData());
    assertEquals(dataAwareEntryEvent.getOldValue(), clonedDataAwareEntryEvent.getOldValue());
    assertEquals(dataAwareEntryEvent.getOldValueData(), clonedDataAwareEntryEvent.getOldValueData());
    assertEquals(dataAwareEntryEvent.getMergingValue(), clonedDataAwareEntryEvent.getMergingValue());
    assertEquals(dataAwareEntryEvent.getMergingValueData(), clonedDataAwareEntryEvent.getMergingValueData());
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) DataAwareEntryEventConstructor(com.hazelcast.test.starter.constructor.DataAwareEntryEventConstructor) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) DataAwareEntryEvent(com.hazelcast.map.impl.DataAwareEntryEvent) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Member (com.hazelcast.cluster.Member)1 Data (com.hazelcast.internal.serialization.Data)1 SerializationService (com.hazelcast.internal.serialization.SerializationService)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 DataAwareEntryEvent (com.hazelcast.map.impl.DataAwareEntryEvent)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 DataAwareEntryEventConstructor (com.hazelcast.test.starter.constructor.DataAwareEntryEventConstructor)1 Test (org.junit.Test)1