@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());
  }
  @Test
  public void testConstructor() {
    SerializedEventMessage<Object> message1 =
        new SerializedEventMessage<Object>(
            eventId, timestamp, serializedPayload, serializedMetaData, serializer);

    assertSame(MetaData.emptyInstance(), message1.getMetaData());
    assertEquals(Object.class, message1.getPayloadType());
    assertFalse(message1.isPayloadDeserialized());
    assertEquals(Object.class, message1.getPayload().getClass());
    assertTrue(message1.isPayloadDeserialized());
  }