@Test public void verifyInterceptorChainIsProceeded() throws Throwable { CommandMessage<AuthorizeCommand> command = new GenericCommandMessage<>(new AuthorizeCommand(CHARGING_STATION_ID, IDENTIFYING_TOKEN, NULL_USER_IDENTITY_CONTEXT)) .withMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); UnitOfWork unitOfWork = mock(UnitOfWork.class); InterceptorChain chain = mock(InterceptorChain.class); new CorrelationCommandHandlerInterceptor().handle(command, unitOfWork, chain); verify(chain).proceed(); }
@Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); }
CorrelationCommandHandlerInterceptor implements CommandHandlerInterceptor { @Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); } }
CorrelationCommandHandlerInterceptor implements CommandHandlerInterceptor { @Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); }  }
CorrelationCommandHandlerInterceptor implements CommandHandlerInterceptor { @Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); }  @Override Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain); }
CorrelationCommandHandlerInterceptor implements CommandHandlerInterceptor { @Override public Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain) throws Throwable { CommandMessage<?> commandWithKeyAdded = null; if (!command.getMetaData().containsKey(CorrelationToken.KEY)) { commandWithKeyAdded = command.andMetaData(Collections.singletonMap(CorrelationToken.KEY, new CorrelationToken())); } UnitOfWorkListener listener = new CorrelationUnitOfWorkListener(commandWithKeyAdded != null ? commandWithKeyAdded : command); unitOfWork.registerListener(listener); return chain.proceed(); }  @Override Object handle(CommandMessage<?> command, UnitOfWork unitOfWork, InterceptorChain chain);  }