コード例 #1
0
  @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());
  }
コード例 #2
0
 @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);
 }