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

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


        return byUsername;
    }

    private void createRaveUserFromLdapInfo(DirContextOperations ctx, String username) {
        User newUser = new UserImpl();
        newUser.setUsername(username);

        if (!ctx.attributeExists(mailAttributeName) || StringUtils.isBlank(ctx.getStringAttribute(mailAttributeName))) {
            throw new RuntimeException("Missing LDAP attribute for email for user " + username);
        }

        newUser.setEmail(ctx.getStringAttribute(mailAttributeName));
        if (ctx.attributeExists(displayNameAttributeName)) {
            newUser.setDisplayName(ctx.getStringAttribute(displayNameAttributeName));
        }
        newUser.setPassword(RandomStringUtils.random(16));
        newUser.setDefaultPageLayoutCode(pageLayoutCode);
        try {
            newAccountService.createNewAccount(newUser);
        } catch (Exception e) {
            throw new RuntimeException("Could not bind LDAP username '{" + username + "}' to a user", e);
        }
View Full Code Here


    }

    @Test
    public void getByUsername_Valid() {
        String username = "username";
        User found = new UserImpl();
        expect(template.findOne(query(where("username").is(username)))).andReturn(found);
        replay(template);
        assertThat(found, is(sameInstance(userRepository.getByUsername(username))));
    }
View Full Code Here

    }

    @Test
    public void getByUserEmail_Valid(){
        String userEmail = "userEmail";
        User found = new UserImpl();
        expect(template.findOne(query(where("email").is(userEmail)))).andReturn(found);
        replay(template);
        assertThat(found, is(sameInstance(userRepository.getByUserEmail(userEmail))));
    }
View Full Code Here

    }

    @Test
    public void getByOpenId_Valid(){
        String openId = "openId";
        User found = new UserImpl();
        expect(template.findOne(query(where("openId").is(openId)))).andReturn(found);
        replay(template);
        assertThat(found, is(sameInstance(userRepository.getByOpenId(openId))));
    }
View Full Code Here

        String ownerId = "ABC";
        Set<String> userIds = Sets.newHashSet();
        userIds.add(ownerId);

        expect(aggregator.getUsersWithWidget(widgetId)).andReturn(userIds);
        UserImpl owner = new UserImpl(ownerId);
        expect(template.get(ownerId)).andReturn(owner);
        replay(template, aggregator);

        List<User> users = userRepository.getAllByAddedWidget(widgetId);
View Full Code Here

    }

    @Test
    public void getByForgotPasswordHash_Valid(){
        String hash = "hashbrown";
        User found = new UserImpl();
        expect(template.findOne(query(where("forgotPasswordHash").is(hash)))).andReturn(found);
        replay(template);

        assertThat(found, is(sameInstance(userRepository.getByForgotPasswordHash(hash))));
    }
View Full Code Here

    }

    @Test
    public void get_Valid(){
        String id = "123";
        User user = new UserImpl();
        expect(template.get(id)).andReturn(user);
        replay(template);
        assertThat(user, is(sameInstance(userRepository.get(id))));
    }
View Full Code Here

        assertThat(user, is(sameInstance(userRepository.get(id))));
    }

    @Test
    public void save_Valid(){
        User item = new UserImpl();
        User saved = new UserImpl();
        expect(template.save(item)).andReturn(saved);
        replay(template);
        assertThat(saved, is(sameInstance(userRepository.save(item))));
    }
View Full Code Here

        assertThat(saved, is(sameInstance(userRepository.save(item))));
    }

    @Test
    public void delete_Valid(){
        User item = new UserImpl();
        ((UserImpl)item).setId("777");
        template.remove(query(where("_id").is(item.getId())));
        expectLastCall();
        replay(template);

        userRepository.delete(item);
        verify(template);
View Full Code Here

        verify(userDetails, passwordEncoder, userService, pageLayoutService);
    }

    @Test
    public void createNewAccountTest_blankEmail() throws Exception {
        UserImpl newUser = new UserImpl();
        newUser.setUsername(VALID_USER);
        newUser.setPassword(VALID_PASSWORD);
        newUser.setConfirmPassword(VALID_PASSWORD);
        newUser.setEmail("");
        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.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.