Package org.apache.rave.model

Examples of org.apache.rave.model.Authority


        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


* Time: 10:42 AM
*/
public class MongoDbAuthorityTest {
    @Test
    public void testAuthority(){
        Authority auth = new MongoDbAuthority();
        String id = "123";
        ((MongoDbAuthority)auth).setId(id);
        assertThat(((MongoDbAuthority) auth).getId(), is(equalTo(id)));
    }
View Full Code Here

        assertTrue(user.getAuthorityCodes().isEmpty());
    }

    @Test
    public void setAuthorities_Valid(){
        Authority auth = new AuthorityImpl();
        auth.setAuthority("auth");
        user.setAuthorities(Arrays.asList(auth));

        assertNotNull(user.getAuthorityCodes());
        assertThat(user.getAuthorityCodes().get(0), is(sameInstance(auth.getAuthority())));
    }
View Full Code Here

        assertTrue(granted.size() == 1);
    }

    @Test
    public void addAuthority_Valid(){
        Authority authority = new AuthorityImpl();
        authority.setAuthority("auth");
        user.addAuthority(authority);
        assertTrue(user.getAuthorityCodes().contains(authority.getAuthority()));
    }
View Full Code Here

        assertTrue(user.getAuthorityCodes().contains(authority.getAuthority()));
    }

    @Test
    public void addAuthority_Contains(){
        Authority authority = new AuthorityImpl();
        authority.setAuthority("auth");
        List<String> authorityCodes = Arrays.asList(authority.getAuthority());
        user.setAuthorityCodes(authorityCodes);
        user.addAuthority(authority);
    }
View Full Code Here

        user.addAuthority(authority);
    }

    @Test
    public void removeAuthority_Valid(){
        Authority auth = new AuthorityImpl();
        auth.setAuthority("stinky");
        user.setAuthorityCodes(new ArrayList<String>());
        user.getAuthorityCodes().add("stinky");

        user.removeAuthority(auth);
View Full Code Here

        assertFalse(user.getAuthorityCodes().contains("stinky"));
    }

    @Test
    public void removeAuthority_NotContain(){
        Authority auth = new AuthorityImpl();
        user.removeAuthority(auth);
        assertNotNull(user.getAuthorityCodes());
    }
View Full Code Here

     */
    private class AuthorityEditor extends PropertyEditorSupport {

        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            Authority authority = authorityService.getAuthorityByName(text);
            setValue(authority);
        }
View Full Code Here

        assertNotNull(authority);
    }

    @Test
    public void convert_Valid(){
        Authority authority = new AuthorityImpl();
        authority.setAuthority("asd;lkfjlkj");
        authority.setDefaultForNewUser(true);

        MongoDbAuthority converted = authorityConverter.convert(authority);
        assertNotNull(converted.getAuthority());
        //assertNotNull(converted.getId());
        assertThat(converted.getAuthority(), is(sameInstance(authority.getAuthority())));
        assertThat(converted.isDefaultForNewUser(), is(sameInstance(authority.isDefaultForNewUser())));

        Authority authorityMongo = new MongoDbAuthority();
        authorityMongo.setAuthority("authority");
        authorityMongo.setDefaultForNewUser(true);
        MongoDbAuthority mongoConverted = authorityConverter.convert(authorityMongo);
        assertThat(mongoConverted, is(sameInstance(authorityMongo)));
        assertThat(mongoConverted.getAuthority(), is(sameInstance(authorityMongo.getAuthority())));
        assertThat(mongoConverted.isDefaultForNewUser(), is(sameInstance(authorityMongo.isDefaultForNewUser())));
    }
View Full Code Here

     */
    private class AuthorityEditor extends PropertyEditorSupport {

        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            Authority authority = authorityService.getAuthorityByName(text);
            setValue(authority);
        }
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.