@Test
  public void testWithMetaData() {
    Map<String, Object> metaDataMap = Collections.singletonMap("key", (Object) "value");
    MetaData metaData = MetaData.from(metaDataMap);
    when(serializer.deserialize(serializedMetaData)).thenReturn(metaData);
    SerializedEventMessage<Object> message =
        new SerializedEventMessage<Object>(
            eventId, timestamp, serializedPayload, serializedMetaData, serializer);
    EventMessage<Object> message1 = message.withMetaData(MetaData.emptyInstance());
    EventMessage<Object> message2 =
        message.withMetaData(MetaData.from(Collections.singletonMap("key", (Object) "otherValue")));

    assertEquals(0, message1.getMetaData().size());
    assertEquals(1, message2.getMetaData().size());
  }
Exemplo n.º 2
0
  @Test
  public void ln_serialization() throws IOException {
    HTreeMap.LinkedNode n = new HTreeMap.LinkedNode(123456, 123L, 456L);

    DataOutput2 out = new DataOutput2();

    Serializer ln_serializer = new HTreeMap(recman, true).LN_SERIALIZER;
    ln_serializer.serialize(out, n);

    DataInput2 in = swap(out);

    HTreeMap.LinkedNode n2 = (HTreeMap.LinkedNode) ln_serializer.deserialize(in, -1);

    assertEquals(123456, n2.next);
    assertEquals(123L, n2.key);
    assertEquals(456L, n2.value);
  }
 @Before
 public void setUp() {
   when(serializer.deserialize(serializedMetaData)).thenReturn(deserializedMetaData);
   when(serializer.deserialize(serializedPayload)).thenReturn(deserializedPayload);
   when(serializer.classForType(isA(SerializedType.class))).thenReturn(Object.class);
 }