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