Package org.apache.rave.model

Examples of org.apache.rave.model.User


    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


    }

    @Test
    public void testLoadUserByUsername() throws Exception {
        final String username = "canonical";
        User user = new UserImpl("1", username);
        expect(repository.getByUsername(username)).andReturn(user);
        replay(repository);

        UserDetails returnedUser = userService.loadUserByUsername(username);
        verify(repository);
View Full Code Here

        grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));
        UserDetails userDetails = new UserImpl("1", "canonical");
        Authentication authentication = new TestingAuthenticationToken(userDetails, "canonical", grantedAuthorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);

        User returnedUser = userService.getAuthenticatedUser();
        assertEquals(returnedUser, userDetails);
    }
View Full Code Here

    private BlobCrypterSecurityToken getBlobCrypterSecurityToken(RegionWidget regionWidget, Widget widget)
            throws SecurityTokenException {
        String moduleUrl = widget != null ? widget.getUrl() : "";
        String moduleId = String.valueOf(regionWidget.getId());
        String ownerId = regionWidget.getRegion().getPage().getOwnerId();
        User user = userService.getAuthenticatedUser();

        BlobCrypterSecurityToken securityToken = getBlobCrypterSecurityToken(moduleUrl, moduleId, ownerId, user);

        if (logger.isTraceEnabled()) {
            logger.trace("Token created for regionWidget " + regionWidget.toString() + " and user " + user.toString());
        }

        return securityToken;
    }
View Full Code Here

     */
    @Test
    @Ignore //This should just merge in rather than throw an exception, which it looks like it does correctly
    public void save_duplicateText_exception() {
        Date now = new Date();
        User user = new JpaUser(1L);

        JpaCategory wc = new JpaCategory();
        wc.setText(DUPLICATE_TEXT_VALUE);
        wc.setCreatedDate(now);
        wc.setCreatedUserId(user.getId());
        wc.setLastModifiedDate(now);
        wc.setLastModifiedUserId(user.getId());

        boolean gotExpectedException = false;
        try {
            repository.save(wc);
            manager.flush();
View Full Code Here

      && exception.getAuthentication() instanceof OpenIDAuthenticationToken
            && ((OpenIDAuthenticationToken)exception.getAuthentication()).getStatus().equals(OpenIDAuthenticationStatus.SUCCESS)) {
     
      OpenIDAuthenticationToken token = (OpenIDAuthenticationToken)exception.getAuthentication();
      String url = token.getIdentityUrl();
      User user = createTemporaryUser(token, url);
      request.getSession(true).setAttribute(ModelKeys.NEW_USER, user);

      DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
      log.info("Redirecting to new user account creation page");
      super.setRedirectStrategy(redirectStrategy);
View Full Code Here

      } else if ("fullname".equals(attribute.getName())
          && !attribute.getValues().isEmpty()) {
        displayName = attribute.getValues().get(0);
      }
    }
    User user = new UserImpl();
    String username = StringUtils.substringAfter(openId, "://").replace("/", "");
    if (username.length() > 35) {
      username = username.substring(0, 35);
    }
    if (displayName == null && firstName != null && lastName != null) {
      displayName = firstName + " " + lastName;
    }
    user.setUsername(username);
    user.setEmail(email);
    user.setGivenName(firstName);
    user.setFamilyName(lastName);
    user.setDisplayName(displayName);
    user.setOpenId(openId);

    return user;
  }
View Full Code Here

    @Rollback(true)
    public void save_new() {
        Date createdDate = new Date();
        Date lastModDate = new Date();
        String text = "my comment";
        User user = new UserImpl(VALID_USER_ID.toString());

        JpaWidgetComment wc = new JpaWidgetComment();
        wc.setCreatedDate(createdDate);
        wc.setWidgetId(VALID_WIDGET_ID.toString());
        wc.setLastModifiedDate(lastModDate);
View Full Code Here

    private ModelUtils() {}


    public static User convert(UserForm form) {
        User newUser = new UserImpl(form.getId(),  form.getUsername());
        newUser.setAuthorities(CollectionUtils.<Authority>toBaseTypedCollection(form.getAuthorities()));
        newUser.setPassword(form.getPassword());
        newUser.setConfirmPassword(form.getConfirmPassword());
        newUser.setForgotPasswordHash(form.getForgotPasswordHash());
        newUser.setDefaultPageLayoutCode(form.getDefaultPageLayoutCode());
        newUser.setStatus(form.getStatus());
        newUser.setAboutMe(form.getAboutMe());
        newUser.setGivenName(form.getGivenName());
        newUser.setFamilyName(form.getFamilyName());
        newUser.setDisplayName(form.getDisplayName());
        newUser.setEmail(form.getEmail());
        newUser.setOpenId(form.getOpenId());
        newUser.setEnabled(form.isEnabled());
        newUser.setExpired(form.isExpired());
        newUser.setLocked(form.isLocked());
        return newUser;
    }
View Full Code Here

        newUser.setPassword(VALID_PASSWORD);
        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setEmail(VALID_EMAIL);
        newUser.setDefaultPageLayoutCode(VALID_LAYOUT_CODE);

        User expectedUser = new UserImpl();
        expectedUser.setUsername(newUser.getUsername());
        expectedUser.setPassword(newUser.getPassword());
        expectedUser.setEmail(newUser.getEmail());
        expectedUser.setDefaultPageLayout(validPageLayout);
        expectedUser.setExpired(false);
        expectedUser.setLocked(false);
        expectedUser.setEnabled(true);

        ReflectionTestUtils.setField(newAccountService, "passwordEncoder", passwordEncoder);

        expect(passwordEncoder.encode("valid.password")).andReturn("valid.password");
        expect(userService.getUserByUsername(VALID_USER)).andReturn(null);
View Full Code Here

TOP

Related Classes of org.apache.rave.model.User

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.