UserEventController { @RequestMapping(value = "/createdEvent", method = RequestMethod.POST) public ResponseEntity<String> publishCreatedEvent(@RequestBody(required = true) UserCreatedEvent userCreatedEvent, HttpServletResponse response) { log.debug("Adding User [{}] '{}'", userCreatedEvent.getId(), userCreatedEvent.getEmail()); CreateUserCommand command = new CreateUserCommand(userCreatedEvent.getId() , userCreatedEvent.getEmail(), userCreatedEvent.getFirstName(), userCreatedEvent.getLastName()); commandGateway.sendAndWait(command); log.info("Added User [{}] '{}'", userCreatedEvent.getId(), userCreatedEvent.getEmail()); response.setStatus(HttpServletResponse.SC_CREATED); return new ResponseEntity<String>("true", HttpStatus.CREATED); }  @RequestMapping(value = "/createdEvent", method = RequestMethod.POST) ResponseEntity<String> publishCreatedEvent(@RequestBody(required = true) UserCreatedEvent userCreatedEvent,
                    HttpServletResponse response); @Autowired
    public CommandGateway commandGateway; }
@Test public void testAddWithGoodRequestParams() { userEventController.commandGateway = gateway; when(gateway.sendAndWait(any())).thenReturn(null); UserCreatedEvent userCreatedEvent = new UserCreatedEvent(); userCreatedEvent.setId(1L); userCreatedEvent.setEmail("Test Create User"); userEventController.publishCreatedEvent(userCreatedEvent, mockHttpServletResponse); verify(gateway).sendAndWait(any()); assertTrue(mockHttpServletResponse.getStatus() == HttpServletResponse.SC_CREATED); }