@Test public void testAvailable() throws Exception { String username = "JanKowalski"; mockMvc.perform(get("/register/is-available") .param("username", username)) .andExpect(status().isOk()); verify(userService, times(1)) .findOne(username); verifyNoMoreInteractions(userService); }
@RequestMapping("is-available") @ResponseBody public String available(@RequestParam String username) { Boolean available = userService.findOne(username) == null; return available.toString(); }
RegisterController { @RequestMapping("is-available") @ResponseBody public String available(@RequestParam String username) { Boolean available = userService.findOne(username) == null; return available.toString(); } }
RegisterController { @RequestMapping("is-available") @ResponseBody public String available(@RequestParam String username) { Boolean available = userService.findOne(username) == null; return available.toString(); } @Autowired  RegisterController(IUserService userService); }
RegisterController { @RequestMapping("is-available") @ResponseBody public String available(@RequestParam String username) { Boolean available = userService.findOne(username) == null; return available.toString(); } @Autowired  RegisterController(IUserService userService); @RequestMapping String showRegisterForm(Model model); @RequestMapping(method = RequestMethod.POST) String registerUser(
            @Valid @ModelAttribute("aUser") UserEntity userEntity,
            BindingResult results); @RequestMapping("is-available") @ResponseBody String available(@RequestParam String username); }
RegisterController { @RequestMapping("is-available") @ResponseBody public String available(@RequestParam String username) { Boolean available = userService.findOne(username) == null; return available.toString(); } @Autowired  RegisterController(IUserService userService); @RequestMapping String showRegisterForm(Model model); @RequestMapping(method = RequestMethod.POST) String registerUser(
            @Valid @ModelAttribute("aUser") UserEntity userEntity,
            BindingResult results); @RequestMapping("is-available") @ResponseBody String available(@RequestParam String username);  }