UserController { @RequestMapping(value="/edit/{loginName:" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "}", method=RequestMethod.GET) @PreAuthorize("hasApplicationPermission(ADMIN)") public String editUser(@PathVariable String loginName, Model model) throws IOException { User user; if (loginName.equals(UserStore.ANONYMOUS_USER_LOGIN_NAME)) { user = new User(UserStore.ANONYMOUS_USER_LOGIN_NAME, null, "anonymous@example.com", false); } else { user = userStore.getUser(loginName); } UserForm form = new UserForm(loginName, loginName, StringUtils.EMPTY, StringUtils.EMPTY, user.getEmail(), user.isDisabled(), null); model.addAttribute("userForm", form); return "/user/edit"; }  @RequestMapping(value="/add", method=RequestMethod.GET) @PreAuthorize("hasApplicationPermission(ADMIN)") String addUser(Model model); @RequestMapping(value="/save", method=RequestMethod.POST) @PreAuthorize("hasApplicationPermission(ADMIN)") String saveUser(@ModelAttribute @Valid UserForm form, BindingResult bindingResult,
			Authentication authentication); @RequestMapping(value="/edit/{loginName:" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "}", method=RequestMethod.GET) @PreAuthorize("hasApplicationPermission(ADMIN)") String editUser(@PathVariable String loginName, Model model); @RequestMapping(value="/delete/{loginName:" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "}", method=RequestMethod.GET) @PreAuthorize("hasApplicationPermission(ADMIN) and !isAdmin(#loginName)") String deleteUser(@PathVariable String loginName, Authentication authentication); @ModelAttribute UserForm createUserForm(@RequestParam(required=false) String loginName,
			@RequestParam(required=false) String originalLoginName,
			@RequestParam(required=false) String password1, @RequestParam(required=false) String password2,
			@RequestParam(required=false) String email, @RequestParam(required=false) boolean disabled,
			@RequestParam(required=false) String authorities);  }
@Test public void editUser() throws IOException { User user = new User("user", "pw", "email", false); when(userStore.getUser("user")).thenReturn(user); String view = userController.editUser("user", model); assertEquals("/user/edit", view); verify(model).addAttribute(eq("userForm"), argUserForm("user", StringUtils.EMPTY, StringUtils.EMPTY, false)); }