new Object(),
Collections.singletonMap("key", (Object) "Value"))));
entityManager.flush();
entityManager.clear();
DomainEventStream events = testSubject.readEvents("test", aggregate1.getIdentifier());
List<DomainEventMessage> actualEvents = new ArrayList<DomainEventMessage>();
while (events.hasNext()) {
DomainEventMessage event = events.next();
event.getPayload();
event.getMetaData();
actualEvents.add(event);
}
assertEquals(aggregate1.getUncommittedEventCount(), actualEvents.size());
/// we make sure persisted events have the same MetaData alteration logic
DomainEventStream other = testSubject.readEvents("test", aggregate2.getIdentifier());
assertTrue(other.hasNext());
DomainEventMessage messageWithMetaData = other.next();
DomainEventMessage altered = messageWithMetaData.withMetaData(Collections.singletonMap("key2",
(Object) "value"));
DomainEventMessage combined = messageWithMetaData.andMetaData(Collections.singletonMap("key2",
(Object) "value"));
assertTrue(altered.getMetaData().containsKey("key2"));