@Test void testTimestampInEventMessageIsAlwaysSerialized() throws IOException, ClassNotFoundException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); GenericEventMessage<String> testSubject = new GenericEventMessage<>(new GenericMessage<>("payload", Collections.singletonMap("key", "value")), Instant::now); oos.writeObject(testSubject); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); Object read = ois.readObject(); assertEquals(GenericEventMessage.class, read.getClass()); assertNotNull(((GenericEventMessage<?>) read).getTimestamp()); }
@Override public Instant getTimestamp() { return timestampSupplier.get(); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public Instant getTimestamp() { return timestampSupplier.get(); } }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public Instant getTimestamp() { return timestampSupplier.get(); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public Instant getTimestamp() { return timestampSupplier.get(); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); @SuppressWarnings("unchecked") static EventMessage<T> asEventMessage(Object event); @Override Instant getTimestamp(); @Override GenericEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericEventMessage<T> andMetaData(Map<String, ?> metaData); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public Instant getTimestamp() { return timestampSupplier.get(); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); @SuppressWarnings("unchecked") static EventMessage<T> asEventMessage(Object event); @Override Instant getTimestamp(); @Override GenericEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericEventMessage<T> andMetaData(Map<String, ?> metaData); static Clock clock; }