Package org.apache.rave.model

Examples of org.apache.rave.model.Authority


        validPageLayout = new PageLayoutImpl();
        validPageLayout.setNumberOfRegions(4L);
        validPageLayout.setCode(VALID_LAYOUT_CODE);

        Authority role1 = new AuthorityImpl();
        role1.setAuthority("DEFAULT_ROLE1");
        Authority role2 = new AuthorityImpl();
        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


        return new SearchResult<User>(users, totalResult);
    }

    private static SearchResult<Authority> createSearchResultWithTwoAuthorities() {
        List<Authority> authorities = new ArrayList<Authority>();
        Authority foo = new AuthorityImpl();
        foo.setAuthority("FOO");
        Authority bar = new AuthorityImpl();
        bar.setAuthority("BAR");
        authorities.add(foo);
        authorities.add(bar);
        return new SearchResult<Authority>(authorities, authorities.size());
    }
View Full Code Here

        assertThat(user.getOpenId(), is(equalTo(OPENID)));
    }

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

        int usercount = authority.getUsers().size();
        User user = new JpaUser();
        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("1");
        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

        throw new NotSupportedException();
    }

    @Override
    public Authority save(Authority item) {
        Authority fromDb = getByAuthority(item.getAuthority());
        Authority save;
        if(fromDb == null) {
            save = converter.convert(item, Authority.class);
        } else {
            fromDb.setDefaultForNewUser(item.isDefaultForNewUser());
            save=fromDb;
View Full Code Here

        service = new DefaultAuthorityService(repository);
    }

    @Test
    public void getAuthorityById() {
        Authority authority = createAuthority();

        expect(repository.get("123")).andReturn(authority);
        replay(repository);
        Authority sAuthority = service.getAuthorityById("123");
        assertEquals(sAuthority, authority);

        verify(repository);
    }
View Full Code Here

        verify(repository);
    }

    @Test
    public void getAuthorityByName() {
        Authority authority = createAuthority();

        expect(repository.getByAuthority("FOO")).andReturn(authority);
        replay(repository);
        Authority sAuthority = service.getAuthorityByName("FOO");
        assertEquals(sAuthority, authority);

        verify(repository);

    }
View Full Code Here

        authority.setAuthority("BAR");
        final String entityId = "456";

        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 AuthorityImpl();
        foo.setAuthority("FOO");
        Authority bar = new AuthorityImpl();
        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 AuthorityImpl();
        foo.setAuthority("FOO");
        foo.setDefaultForNewUser(true);
        Authority bar = new AuthorityImpl();
        bar.setAuthority("BAR");
        bar.setDefaultForNewUser(true);
       
        authorities.add(foo);
        authorities.add(bar);

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

TOP

Related Classes of org.apache.rave.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.