Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.Authority


        verify(repository);

    }

    private static Authority createAuthority() {
        Authority authority = new Authority();
        authority.setAuthority("FOO");
        final long entityId = 123L;
        authority.setEntityId(entityId);
        return authority;
    }
View Full Code Here


        return authority;
    }

    @Test
    public void getAuthorityById_NotFound() {
        Authority authority = new Authority();
        authority.setAuthority("BAR");
        final long entityId = 456L;
        authority.setEntityId(entityId);

        expect(repository.get(entityId)).andReturn(null);
        replay(repository);
        Authority sAuthority = service.getAuthorityById(entityId);
        assertNull(sAuthority);

        verify(repository);
    }
View Full Code Here

    }

    @Test
    public void allAuthorities() {
        List<Authority> authorities = new ArrayList<Authority>();
        Authority foo = new Authority();
        foo.setAuthority("FOO");
        Authority bar = new Authority();
        bar.setAuthority("BAR");
        authorities.add(foo);
        authorities.add(bar);

        expect(repository.getAll()).andReturn(authorities);
        expect(repository.getCountAll()).andReturn(authorities.size());
View Full Code Here

    }
   
    @Test
    public void test_getAllDefault() {
        List<Authority> authorities = new ArrayList<Authority>();
        Authority foo = new Authority();
        foo.setAuthority("FOO");
        foo.setDefaultForNewUser(true);
        Authority bar = new Authority();
        bar.setAuthority("BAR");
        bar.setDefaultForNewUser(true);
       
        authorities.add(foo);
        authorities.add(bar);

        expect(repository.getAllDefault()).andReturn(authorities);
View Full Code Here

        assertThat(user.getEmail(), is(equalTo(USER_EMAIL)));
    }

    @Test
    public void addOrDeleteUserDoesNotAffectAuthority() {
        Authority authority = authorityRepository.get(1L);
        Assert.assertNotNull("Existing authority", authority);

        int usercount = authority.getUsers().size();
        User user = new User();
        user.setUsername("dummy");
        authority.addUser(user);
        authorityRepository.save(authority);
        assertNull("Persisting an Authority does not persist an unknown user", repository.getByUsername("dummy"));
        Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());

        repository.save(user);
        user = repository.getByUsername("dummy");
        Assert.assertNotNull(user);
        Assert.assertEquals("Authority has 1 more user", usercount + 1, authority.getUsers().size());

        repository.delete(user);
        authority = authorityRepository.get(1L);
        Assert.assertNotNull("Authority has not been removed after deleting user", authority);
        Assert.assertEquals("Authority has original amount of users", usercount, authority.getUsers().size());
    }
View Full Code Here

        validPageLayout = new PageLayout();
        validPageLayout.setEntityId(99L);
        validPageLayout.setNumberOfRegions(4L);
        validPageLayout.setCode(VALID_LAYOUT_CODE);

        Authority role1 = new Authority();
        role1.setAuthority("DEFAULT_ROLE1");
        Authority role2 = new Authority();
        role2.setAuthority("DEFAULT_ROLE2");

        validAuthorityList = new ArrayList<Authority>();
        validAuthorityList.add(role1);
        validAuthorityList.add(role2);
        validAuthoritySearchResult = new SearchResult<Authority>(validAuthorityList, validAuthorityList.size());
View Full Code Here

    private static final Long VALID_ID = 1L;

    @Test
    public void getById_validId() {
        final Authority authority = repository.get(VALID_ID);
        assertNotNull(authority);
        assertEquals(VALID_ID, authority.getEntityId());
    }
View Full Code Here

    }

    @Test
    public void getByAuthorityName() {
        String authorityName = "administrator";
        Authority authority = repository.getByAuthority(authorityName);
        assertNotNull(authority);
        assertEquals(authorityName, authority.getAuthority());
        assertTrue(authority.getUsers().isEmpty());
    }
View Full Code Here

    }

    @Test
    public void getUsersByAuthorityName() {
        String authorityName = "administrator";
        Authority authority = repository.getByAuthority(authorityName);
        assertNotNull(authority);
        assertEquals(authorityName, authority.getAuthority());
        assertTrue(authority.getUsers().isEmpty());

        User newUser = new User();
        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 Authority();
        authority.setAuthority(authorityName);
        User user = userRepository.get(1L);

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

TOP

Related Classes of org.apache.rave.portal.model.Authority

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.