Examples of UserForm


Examples of org.apache.rave.portal.web.model.UserForm

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

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

        newAccountService.createNewAccount(isA(User.class));

        replay(model);
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

    authUser.setFamilyName("Rave");
    authUser.setAboutMe("Test User");
    authUser.setEmail("testuser@rave.com");

    //creating a mock updated user
    final UserForm updatedUser = new UserForm();
    //set the updated status
    updatedUser.setStatus("Married");
    updatedUser.setGivenName("Test");
    updatedUser.setFamilyName("Rave");
    updatedUser.setAboutMe("Test User");
    updatedUser.setEmail("testuser@rave.com");

    expect(userService.getAuthenticatedUser()).andReturn(authUser).anyTimes();
    userService.updateUserProfile(authUser);
    replay(userService);

    String view = profileController.updateProfile(model, referringPageId, updatedUser);

    //assert that the model is not null
    assertThat(model, CoreMatchers.notNullValue());

    //assert that the model size is three
    assertThat(model.size(), CoreMatchers.equalTo(modelSize));

    //assert that the model does contain an attribute associated with the authenticated user
    assertThat(model.containsAttribute(userProfile), CoreMatchers.equalTo(true));

    //assert that the model does not contain authenticated user as null
    assertThat(model.get(userProfile), CoreMatchers.notNullValue());

    //assert that the status of user is updated
    assertEquals(updatedUser.getStatus(), authUser.getStatus());

        assertThat(view, is("redirect:/app/person/" + USERNAME));

    verify(userService);
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

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

Examples of org.apache.rave.portal.web.model.UserForm

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

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

        newAccountService.createNewAccount(isA(User.class));

        replay(model);
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

    authUser.setFamilyName("Rave");
    authUser.setAboutMe("Test User");
    authUser.setEmail("testuser@rave.com");

    //creating a mock updated user
    final UserForm updatedUser = new UserForm();
    //set the updated status
    updatedUser.setStatus("Married");
    updatedUser.setGivenName("Test");
    updatedUser.setFamilyName("Rave");
    updatedUser.setAboutMe("Test User");
    updatedUser.setEmail("testuser@rave.com");

    expect(userService.getAuthenticatedUser()).andReturn(authUser).anyTimes();
    userService.updateUserProfile(authUser);
    replay(userService);

    String view = profileController.updateProfile(model, referringPageId, updatedUser);

    //assert that the model is not null
    assertThat(model, CoreMatchers.notNullValue());

    //assert that the model size is three
    assertThat(model.size(), CoreMatchers.equalTo(modelSize));

    //assert that the model does contain an attribute associated with the authenticated user
    assertThat(model.containsAttribute(userProfile), CoreMatchers.equalTo(true));

    //assert that the model does not contain authenticated user as null
    assertThat(model.get(userProfile), CoreMatchers.notNullValue());

    //assert that the status of user is updated
    assertEquals(updatedUser.getStatus(), authUser.getStatus());

        assertThat(view, is("redirect:/app/person/" + USERNAME));

    verify(userService);
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

  }

  @Test
  public void create_UsernameNotSpecified() {
    final Model model = createNiceMock(Model.class);
    final UserForm User = new UserForm();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = ""; //no username specified
    final String password = "password";
    final String confirmPassword = password;
    List<ObjectError> errorList = new ArrayList<ObjectError>();
    final ObjectError error = new ObjectError("username.required", "Username required");

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(error);

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

  }

  @Test
  public void create_UsernameAlreadyExists() {
    final Model model = createNiceMock(Model.class);
    final UserForm User = new UserForm();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "canonical"; //specified username already exists in database
    final String password = "password";
    final String confirmPassword = password;
    final User existingUser = new UserImpl();
    List<ObjectError> errorList = new ArrayList<ObjectError>();
    final ObjectError error = new ObjectError("username.exists", "Username already exists");

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    existingUser.setUsername(username);
    existingUser.setPassword(password);

    errorList.add(error);
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

  }

  @Test
  public void create_InvalidUsernameLength() {
    final Model model = createNiceMock(Model.class);
    final UserForm User = new UserForm();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "u"; //username length less than 2 characters
    final String password = "password";
    final String confirmPassword = password;
    List<ObjectError> errorList = new ArrayList<ObjectError>();
    final ObjectError error = new ObjectError("username.invalid.length", "Username must be atleast 2 characters long");

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(error);

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

  }

  @Test
  public void create_PasswordNotSpecified() {
    final Model model = createNiceMock(Model.class);
    final UserForm User = new UserForm();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "username";
    final String password = ""; //password not specified
    final String confirmPassword = password;
    List<ObjectError> errorList = new ArrayList<ObjectError>();

    User.setUsername(username);
    User.setPassword(password);
    User.setConfirmPassword(confirmPassword);

    errorList.add(new ObjectError("password.required", "Password required"));
    errorList.add(new ObjectError("confirmPassword.required", "Confirm password required"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
View Full Code Here

Examples of org.apache.rave.portal.web.model.UserForm

  }

  @Test
  public void create_ConfirmPasswordNotSpecified() {
    final Model model = createNiceMock(Model.class);
    final UserForm User = new UserForm();
    final BindingResult errors = createNiceMock(BindingResult.class);
    final String username = "usename";
    final String password = "pasword";
    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("confirmPassword.required", "Confirm password required"));

    expect(errors.hasErrors()).andReturn(true).anyTimes();
    expect(errors.getAllErrors()).andReturn(errorList).anyTimes();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.