Package org.apache.rave.portal.model.impl

Examples of org.apache.rave.portal.model.impl.UserImpl


    @Test
    public void updateUserDetail_withErrors() {
        ModelMap modelMap = new ExtendedModelMap();
        String userid = "123";
        UserImpl user = new UserImpl(userid, "john.doe.sr");
        final BindingResult errors = new BeanPropertyBindingResult(user, "user");

        SessionStatus sessionStatus = createMock(SessionStatus.class);
        replay(sessionStatus);
        final String view = controller.updateUserDetail(user, errors, validToken, validToken,REFERRER_ID, modelMap, sessionStatus);
View Full Code Here


    }

    @Test(expected = SecurityException.class)
    public void updateUserDetail_wrongToken() {
        ModelMap modelMap = new ExtendedModelMap();
        UserImpl user = new UserImpl("123", "john.doe.sr");
        final BindingResult errors = new BeanPropertyBindingResult(user, "user");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        sessionStatus.setComplete();

        expectLastCall();
View Full Code Here

    @Test
    public void deleteUserDetail_success() {
        ModelMap modelMap = new ExtendedModelMap();
        String userid = "123";
        final String email = "john.doe.sr@example.net";
        User user = new UserImpl(userid, "john.doe.sr");
        user.setPassword("secrect");
        user.setConfirmPassword(user.getConfirmPassword());
        user.setEmail(email);

        SessionStatus sessionStatus = createMock(SessionStatus.class);

        userService.deleteUser(user.getId());
        sessionStatus.setComplete();
        expectLastCall();
        replay(userService, sessionStatus);

        final String view = controller.deleteUserDetail(user, validToken, validToken, "true",REFERRER_ID, modelMap, sessionStatus);
View Full Code Here

    @Test
    public void deleteUserDetail_noConfirmChecked() {
        ModelMap modelMap = new ExtendedModelMap();
        String userid = "123";
        User user = new UserImpl(userid, "john.doe.sr");

        SessionStatus sessionStatus = createMock(SessionStatus.class);
        replay(sessionStatus);
        final String view = controller.deleteUserDetail(user, validToken, validToken, null,REFERRER_ID, modelMap, sessionStatus);
        verify(sessionStatus);
View Full Code Here

    }

    @Test(expected = SecurityException.class)
    public void deleteUserDetail_wrongToken() {
        ModelMap modelMap = new ExtendedModelMap();
        User user = new UserImpl("123", "john.doe.sr");
        SessionStatus sessionStatus = createMock(SessionStatus.class);
        sessionStatus.setComplete();

        expectLastCall();
        replay(sessionStatus);
View Full Code Here

        controller.setNewAccountService(newAccountService);
    }


    private static SearchResult<User> createSearchResultWithTwoUsers() {
        UserImpl user1 = new UserImpl("123", "john.doe.sr");
        UserImpl user2 = new UserImpl("456", "john.doe.jr");
        List<User> users = new ArrayList<User>();
        users.add(user1);
        users.add(user2);
        final int totalResult = 12390;
        return new SearchResult<User>(users, totalResult);
View Full Code Here

        pageLayoutService = createMock(PageLayoutService.class);
        pageController = new PageController(pageService, userService, pageLayoutService);
        model = new ExtendedModelMap();
        request = new MockHttpServletRequest();

        validUser = new UserImpl(USER_ID);
        validPageLayout = new PageLayoutImpl();
        validPageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
        defaultPageUser = new PageUserImpl(USER_ID, defaultPage, 1L);
        defaultPageUser.setPageStatus(PageInvitationStatus.OWNER);
View Full Code Here

  }

  @Test
  public void viewPerson_ShouldAddAttributeForUser() {
    //creating a mock user
    final UserImpl user = new UserImpl();
    final ModelMap model = new ModelMap();
    final int modelSize = 4;
    final String username="canonical";
        user.setUsername(username);
        user.setId(USER_ID);
    String userProfile = new String(ModelKeys.USER_PROFILE);
        Page personProfile = new PageImpl();
        PageLayout pageLayout = new PageLayoutImpl();
        pageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
        personProfile.setPageLayout(pageLayout);
        List<Person> personObjects = new ArrayList<Person>();

    expect(userService.getUserByUsername(username)).andReturn(user).once();
        expect(pageService.getPersonProfilePage(user.getId())).andReturn(personProfile);
    expect(userService.getFriendRequestsReceived(username)).andReturn(personObjects);

    replay(userService, pageService);

    String view = profileController.viewProfileByUsername(username, model, null, response);
View Full Code Here

  }
 
  @Test
  public void viewPerson_userid() {
    //creating a mock user
    final UserImpl user = new UserImpl();
    final ModelMap model = new ModelMap();
    final int modelSize = 4;
    final String username="canonical";
        user.setUsername(username);
        user.setId(USER_ID);
    String userProfile = new String(ModelKeys.USER_PROFILE);
        Page personProfile = new PageImpl();
        PageLayout pageLayout = new PageLayoutImpl();
        pageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
        personProfile.setPageLayout(pageLayout);
        List<Person> personObjects = new ArrayList<Person>();

    expect(userService.getUserById(USER_ID)).andReturn(user).once();
        expect(pageService.getPersonProfilePage(user.getId())).andReturn(personProfile);
    expect(userService.getFriendRequestsReceived(username)).andReturn(personObjects);

    replay(userService, pageService);

    String view = profileController.viewProfile(USER_ID, model, null, response);
View Full Code Here

    final String referringPageId = "1";
        final String USERNAME = "canonical";
    String userProfile = new String(ModelKeys.USER_PROFILE);

    //creating a mock authenticated user
    final User authUser = new UserImpl();
        authUser.setUsername(USERNAME);
    //set existing status
    authUser.setStatus("Single");
    //set other paramters
    authUser.setGivenName("Test");
    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

TOP

Related Classes of org.apache.rave.portal.model.impl.UserImpl

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.