### Question:
UserController { @RequestMapping(value = "/api/user/uniqueusername", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isUsernameUnique(@RequestParam(value = "key", required = true) String username) { return new UniqueResult(userRepository.isUsernameUnique(username)); } @Autowired  UserController(CommandBus commandBus,
                          UserRepository userRepository); @RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email); @RequestMapping(value = "/api/user/uniqueusername", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) UniqueResult isUsernameUnique(@RequestParam(value = "key", required = true) String username); @RequestMapping(value = "/api/user/register", method = {RequestMethod.POST}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE, consumes = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) void register(@RequestBody RegisterUserDto user);  }### Answer:
@Test public void testIsUsernameUnique() throws Exception { log.info("Testing UserController.isUsernameUnique..."); given(userRepository.isUsernameUnique(UNIQUE_USERNAME)).willReturn(true); given(userRepository.isUsernameUnique(EXISTING_USERNAME)).willReturn(false); log.info("First we expect a unique username"); this.mockMvc.perform(get("/api/user/uniqueusername").param("key", UNIQUE_USERNAME).accept(ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON)) .andDo(print()) .andExpect(status().isOk()) .andExpect(content().contentType(ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON)) .andExpect(jsonPath("$.unique").value(true)); log.info("And now we expect username to already exist"); this.mockMvc.perform(get("/api/user/uniqueusername").param("key", EXISTING_USERNAME).accept(ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON)) .andDo(print()) .andExpect(status().isOk()) .andExpect(content().contentType(ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON)) .andExpect(jsonPath("$.unique").value(false)); log.info("Testing UserController.isUsernameUnique SUCCESSFUL"); }