@Test
public void create_ValidFormSubmitted() throws Exception {
final Model model = createNiceMock(Model.class);
final RedirectAttributes redirectAttributes = createNiceMock(RedirectAttributes.class);
final UserForm User = new UserForm();
final BindingResult errors = new BeanPropertyBindingResult(User, ModelKeys.NEW_USER);
final String username = "username";
final String password = "password";
final String email = "User@example.com";
final String confirmPassword = password;
User.setUsername(username);
User.setPassword(password);
User.setConfirmPassword(confirmPassword);
User.setEmail(email);
expect(userService.getUserByUsername(username)).andReturn(null);
expect(userService.getUserByEmail(email)).andReturn(null);
newAccountService.createNewAccount(isA(User.class));
expectLastCall();
replay(userService, model, newAccountService, redirectAttributes);
String result = controller.create(User, errors, model,REFERRER_ID,redirectAttributes);
verify(userService, model, newAccountService, redirectAttributes);
assertFalse(errors.hasErrors());
assertEquals("redirect:/app/admin/users?referringPageId=" +REFERRER_ID, result);
}