### Question:
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())); } PortfolioManagementUserListener(CommandGateway commandGateway); @EventHandler void on(UserCreatedEvent event);  }### Answer:
@Test public void testOnUserCreatedEventACreatePortfolioCommandIsPublished() { UserId testUserId = new UserId(); testSubject.on(new UserCreatedEvent(testUserId, "Test", "testuser", "testpassword")); ArgumentCaptor<CreatePortfolioCommand> commandCaptor = ArgumentCaptor.forClass(CreatePortfolioCommand.class); verify(commandGateway).send(commandCaptor.capture()); CreatePortfolioCommand result = commandCaptor.getValue(); assertNotNull(result); assertNotNull(result.getPortfolioId()); assertEquals(testUserId, result.getUserId()); }