@Test
public void create_BlankFormSubmitted() {
final Model model = createNiceMock(Model.class);
final UserForm User = new UserForm();
final BindingResult errors = createNiceMock(BindingResult.class);
final String username = ""; //Username not specified
final String password = ""; //Password not specified
final String confirmPassword = ""; //Confirm password not specified
List<ObjectError> errorList = new ArrayList<ObjectError>();
User.setUsername(username);
User.setPassword(password);
User.setConfirmPassword(confirmPassword);
errorList.add(new ObjectError("username.required", "Username required"));
errorList.add(new ObjectError("password.required", "Password required"));
errorList.add(new ObjectError("confirmPassword.required", "Confirm password required"));
expect(errors.hasErrors()).andReturn(true).anyTimes();
expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
replay(errors);
replay(model);
String result = newAccountController.create(User, errors, model, request, redirectAttributes);
errorList = errors.getAllErrors();
assertThat(errorList.size(), CoreMatchers.equalTo(3));
assertThat(errorList.get(0).getDefaultMessage(), CoreMatchers.equalTo("Username required"));
assertThat(errorList.get(1).getDefaultMessage(), CoreMatchers.equalTo("Password required"));
assertThat(errorList.get(2).getDefaultMessage(), CoreMatchers.equalTo("Confirm password required"));