@Test public void onEventRegisteredReturnsEventWithMetaData() { CorrelationToken token = new CorrelationToken(); CommandMessage<AuthorizeCommand> command = new GenericCommandMessage<>(new AuthorizeCommand(CHARGING_STATION_ID, IDENTIFYING_TOKEN, NULL_USER_IDENTITY_CONTEXT)).withMetaData(Collections.singletonMap(CorrelationToken.KEY, token)); UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(command); EventMessage event = listener.onEventRegistered(new DefaultUnitOfWork(), asEventMessage(new AuthorizationRequestedEvent(CHARGING_STATION_ID, IDENTIFYING_TOKEN, NULL_USER_IDENTITY_CONTEXT))); assertTrue(event.getMetaData().get(CorrelationToken.KEY).equals(token)); }
@Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); }
CorrelationUnitOfWorkListener extends UnitOfWorkListenerAdapter { @Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } }
CorrelationUnitOfWorkListener extends UnitOfWorkListenerAdapter { @Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } CorrelationUnitOfWorkListener(CommandMessage<?> command); }
CorrelationUnitOfWorkListener extends UnitOfWorkListenerAdapter { @Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } CorrelationUnitOfWorkListener(CommandMessage<?> command); @Override EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event); }
CorrelationUnitOfWorkListener extends UnitOfWorkListenerAdapter { @Override public <T> EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event) { return event.withMetaData(Collections.singletonMap(CorrelationToken.KEY, correlationToken)); } CorrelationUnitOfWorkListener(CommandMessage<?> command); @Override EventMessage<T> onEventRegistered(UnitOfWork unitOfWork, EventMessage<T> event);  }