PortfolioManagementUserListener { @EventHandler public void on(UserCreatedEvent event) { logger.debug("About to dispatch a new command to create a Portfolio for the new user {}", event.getUserId()); commandGateway.send(new CreatePortfolioCommand(new PortfolioId(), event.getUserId())); } @Autowired  PortfolioManagementUserListener(CommandGateway commandGateway); @EventHandler void on(UserCreatedEvent event);  }
@Test public void checkPortfolioCreationAfterUserCreated() { UserId userId = new UserId(); listener.on(new UserCreatedEvent(userId, "Test", "testuser", "testpassword")); verify(commandGateway).send(argThat(new CreatePortfolioCommandMatcher(userId))); }