Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.NewUser


  }
 
  @Test
  public void create_PasswordMismatchCaseTwo() {
    final Model model = createNiceMock(Model.class);
    final NewUser newUser = new NewUser();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "username";
    final String password = "password";
    final String confirmPassword = "passwodr"; //confirm password mistyped
    List<ObjectError> errorList = new ArrayList<ObjectError>();
       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setConfirmPassword(confirmPassword);
   
    errorList.add(new ObjectError("confirmPassword.mismatch", "Password mismatch"));
   
    expect(errors.hasErrors()).andReturn(true).anyTimes();   
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
View Full Code Here


    @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);
View Full Code Here

  }
 
  @Test
  public void create_BlankFormSubmitted() {
    final Model model = createNiceMock(Model.class);
    final NewUser newUser = new NewUser();
    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>();
       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.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"));
   
View Full Code Here

    }
    @Test
    public void create_EmptyForm() 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 = "";
        final String password = "";
        final String email = "";
        final String confirmPassword = password;

        newUser.setUsername(username);
        newUser.setPassword(password);
        newUser.setConfirmPassword(confirmPassword);
        newUser.setEmail(email);

        newAccountService.createNewAccount(newUser);

        replay(model);
View Full Code Here

  }
 
  @Test
  public void create_ValidFormSubmitted() {
    final Model model = createNiceMock(Model.class);
    final NewUser newUser = new NewUser();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "username"; //Username not specified
    final String password = "password"; //Password not specified
    final String confirmPassword = password; //Confirm password not specified
    List<ObjectError> errorList = new ArrayList<ObjectError>();
       
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setConfirmPassword(confirmPassword);
   
    expect(errors.hasErrors()).andReturn(false).anyTimes();   
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
    replay(errors);
   
View Full Code Here

    @RequestMapping(method = RequestMethod.GET, value = {"/admin/adduser"})
    public String setUpForm(ModelMap model) {
        logger.debug("Initializing new account form");
        AdminControllerUtil.addNavigationMenusToModel(SELECTED_ITEM, (Model) model);
        model.addAttribute(ModelKeys.NEW_USER, new NewUser());
        return ViewNames.ADMIN_NEW_ACCOUNT;

    }
View Full Code Here

    @Test
    public void testUpdate() throws Exception {
        final Model model = createNiceMock(Model.class);
        RedirectAttributes redirectAttributes = createNiceMock(RedirectAttributes.class);
        NewUser newUser = new NewUser();
        replay(redirectAttributes);
        replay(model);
        BindingResult results = new DirectFieldBindingResult(newUser, ModelKeys.NEW_USER);
        String viewName = controller.update(newUser, results, model, redirectAttributes);
        assertThat(viewName, CoreMatchers.equalTo(ViewNames.PASSWORD_CHANGE));
        assertThat(results.hasErrors(), CoreMatchers.equalTo(true));
        assertThat(results.getErrorCount(), CoreMatchers.equalTo(2));
        // invalid password, to short:
        newUser.setPassword("123");
        results = new DirectFieldBindingResult(newUser, ModelKeys.NEW_USER);
        controller.update(newUser, results, model, redirectAttributes);
        assertEquals("Expected password errors", 2, results.getErrorCount());
        assertEquals("Expected password errors", "password.invalid.length", results.getFieldError().getCode());
        // missing password confirm:
        newUser.setPassword("1234");
        results = new DirectFieldBindingResult(newUser, ModelKeys.NEW_USER);
        controller.update(newUser, results, model, redirectAttributes);
        assertEquals("Expected password errors", 1, results.getErrorCount());
        assertEquals("Expected password errors", "confirmPassword.required", results.getFieldError().getCode());
        // password confirm not equal:
        newUser.setPassword("1234");
        newUser.setConfirmPassword("12345");
        results = new DirectFieldBindingResult(newUser, ModelKeys.NEW_USER);
        controller.update(newUser, results, model, redirectAttributes);
        assertEquals("Expected password errors", 1, results.getErrorCount());
        assertEquals("Expected password errors", "confirmPassword.mismatch", results.getFieldError().getCode());

        // ok request
        newUser.setPassword("1234");
        newUser.setConfirmPassword("1234");
        results = new DirectFieldBindingResult(newUser, ModelKeys.NEW_USER);
        controller.update(newUser, results, model, redirectAttributes);
        assertEquals("Expected password errors", 0, results.getErrorCount());

View Full Code Here

    }

    @RequestMapping(value = "/newaccount.jsp")
    public void setUpForm(ModelMap model) {
        logger.debug("Initializing form");
        model.addAttribute(ModelKeys.NEW_USER, new NewUser());
    }
View Full Code Here

        validAuthoritySearchResult = new SearchResult<Authority>(validAuthorityList, validAuthorityList.size());       
    }   
   
    @Test
    public void createNewAccountTest() throws Exception {
        NewUser newUser = new NewUser();
        newUser.setUsername(VALID_USER);
        newUser.setPassword(VALID_PASSWORD);
        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setEmail(VALID_EMAIL);
        newUser.setPageLayout(VALID_LAYOUT_CODE);
       
        User expectedUser = new User();
        expectedUser.setUsername(newUser.getUsername());
        expectedUser.setPassword(newUser.getPassword());
        expectedUser.setEmail(newUser.getEmail());
        expectedUser.setDefaultPageLayout(validPageLayout);
        expectedUser.setExpired(false);
        expectedUser.setLocked(false);
        expectedUser.setEnabled(true);               
       
View Full Code Here

    }

    @Test
    public void failedAccountCreationTest_duplicateUsername() throws Exception {
        String duplicateUserName = "duplicateUserName";
        NewUser newUser = new NewUser();
        newUser.setUsername(duplicateUserName);
        User existingUser = new User();
        existingUser.setUsername(duplicateUserName);

        expect(userService.getUserByUsername(duplicateUserName)).andReturn(existingUser);
        replay(userService);
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.NewUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.