Package org.apache.rave.model

Examples of org.apache.rave.model.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


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

        expect(userService.getUserByUsername(duplicateUserName)).andReturn(existingUser);
        replay(userService);

        try {
View Full Code Here

    public void failedAccountCreationTest_duplicateEmail() throws Exception {
        String duplicateEmail = "duplicateEmail";
        UserImpl newUser = new UserImpl();
        newUser.setUsername("newUser");
        newUser.setEmail(duplicateEmail);
        User existingUser = new UserImpl();
        existingUser.setEmail(duplicateEmail);

        expect(userService.getUserByUsername("newUser")).andReturn(null);
        expect(userService.getUserByEmail(duplicateEmail)).andReturn(existingUser);
        replay(userService);
View Full Code Here

        Authority authority = repository.getByAuthority(authorityName);
        assertNotNull(authority);
        assertEquals(authorityName, authority.getAuthority());
        assertTrue(authority.getUsers().isEmpty());

        User newUser = new JpaUser();
        newUser.setUsername("adminuser");
        newUser.addAuthority(authority);
        newUser = userRepository.save(newUser);
        assertEquals(authority, newUser.getAuthorities().iterator().next());

        authority = repository.getByAuthority(authorityName);
        assertEquals(1, authority.getUsers().size());
    }
View Full Code Here

    @Test
    public void addOrDeleteAuthorityDoesNotAffectUser() {
        final String authorityName = "guest";
        Authority authority = new JpaAuthority();
        authority.setAuthority(authorityName);
        User user = userRepository.get("1");

        Assert.assertNotNull("User is null", user);
        Assert.assertTrue("User has no authorities", user.getAuthorities().isEmpty());
        assertNull("No authority guest", repository.getByAuthority(authorityName));

        user.addAuthority(authority);
        user = userRepository.save(user);

        assertNull("Persisting a user does not persist an unknown Authority", repository.getByAuthority(authorityName));
        repository.save(authority);

        Assert.assertEquals("Found authority", authorityName, user.getAuthorities().iterator().next().getAuthority());
        Assert.assertNotNull("New authority: guest", authority);

        repository.delete(authority);
        assertNull("No authority guest", repository.getByAuthority(authorityName));

        user = userRepository.get("1");
        Assert.assertNotNull("User should not be deleted after removing an authority", user);
        Assert.assertTrue("User should have no authorities", user.getAuthorities().isEmpty());
    }
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

    }

    @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

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.