@Test public void testIsEmailUnique() throws Exception { log.info("Testing UserController.isEmailUnique..."); given(userRepository.isEmailUnique(UNIQUE_EMAIL)).willReturn(true); given(userRepository.isEmailUnique(EXISTING_EMAIL)).willReturn(false); log.info("First we expect a unique email"); this.mockMvc.perform(get("/api/user/uniqueemail").param("key", UNIQUE_EMAIL).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 email to already exist"); this.mockMvc.perform(get("/api/user/uniqueemail").param("key", EXISTING_EMAIL).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.isEmailUnique SUCCESSFUL"); }
@RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email) { return new UniqueResult(userRepository.isEmailUnique(email)); }
UserController { @RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email) { return new UniqueResult(userRepository.isEmailUnique(email)); } }
UserController { @RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email) { return new UniqueResult(userRepository.isEmailUnique(email)); } @Autowired  UserController(CommandBus commandBus,
                          UserRepository userRepository); }
UserController { @RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email) { return new UniqueResult(userRepository.isEmailUnique(email)); } @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); }
UserController { @RequestMapping(value = "/api/user/uniqueemail", method = {RequestMethod.GET}, produces = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) public UniqueResult isEmailUnique(@RequestParam(value = "key", required = true) String email) { return new UniqueResult(userRepository.isEmailUnique(email)); } @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);  }