@Test void testWithMetaData() { Object payload = new Object(); long seqNo = 0; String id = UUID.randomUUID().toString(); Map<String, Object> metaDataMap = Collections.singletonMap("key", "value"); MetaData metaData = MetaData.from(metaDataMap); GenericDomainEventMessage<Object> message = new GenericDomainEventMessage<>("type", id, seqNo, payload, metaData); GenericDomainEventMessage<Object> message1 = message.withMetaData(MetaData.emptyInstance()); GenericDomainEventMessage<Object> message2 = message.withMetaData( MetaData.from(Collections.singletonMap("key", (Object) "otherValue"))); assertEquals(0, message1.getMetaData().size()); assertEquals(1, message2.getMetaData().size()); }
@Override public GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData) { if (getMetaData().equals(metaData)) { return this; } return new GenericDomainEventMessage<>(type, aggregateIdentifier, sequenceNumber, getDelegate().withMetaData(metaData), getTimestamp()); }
GenericDomainEventMessage extends GenericEventMessage<T> implements DomainEventMessage<T> { @Override public GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData) { if (getMetaData().equals(metaData)) { return this; } return new GenericDomainEventMessage<>(type, aggregateIdentifier, sequenceNumber, getDelegate().withMetaData(metaData), getTimestamp()); } }
GenericDomainEventMessage extends GenericEventMessage<T> implements DomainEventMessage<T> { @Override public GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData) { if (getMetaData().equals(metaData)) { return this; } return new GenericDomainEventMessage<>(type, aggregateIdentifier, sequenceNumber, getDelegate().withMetaData(metaData), getTimestamp()); } GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData, String messageIdentifier, Instant timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate,
                                     Supplier<Instant> timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber,
                                     Message<T> delegate, Instant timestamp); }
GenericDomainEventMessage extends GenericEventMessage<T> implements DomainEventMessage<T> { @Override public GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData) { if (getMetaData().equals(metaData)) { return this; } return new GenericDomainEventMessage<>(type, aggregateIdentifier, sequenceNumber, getDelegate().withMetaData(metaData), getTimestamp()); } GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData, String messageIdentifier, Instant timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate,
                                     Supplier<Instant> timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber,
                                     Message<T> delegate, Instant timestamp); @Override String getType(); @Override String getAggregateIdentifier(); @Override long getSequenceNumber(); @Override GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericDomainEventMessage<T> andMetaData(Map<String, ?> metaData); }
GenericDomainEventMessage extends GenericEventMessage<T> implements DomainEventMessage<T> { @Override public GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData) { if (getMetaData().equals(metaData)) { return this; } return new GenericDomainEventMessage<>(type, aggregateIdentifier, sequenceNumber, getDelegate().withMetaData(metaData), getTimestamp()); } GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, T payload,
                                     Map<String, ?> metaData, String messageIdentifier, Instant timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber, Message<T> delegate,
                                     Supplier<Instant> timestamp);  GenericDomainEventMessage(String type, String aggregateIdentifier, long sequenceNumber,
                                     Message<T> delegate, Instant timestamp); @Override String getType(); @Override String getAggregateIdentifier(); @Override long getSequenceNumber(); @Override GenericDomainEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericDomainEventMessage<T> andMetaData(Map<String, ?> metaData);  }