Examples of Authority


Examples of org.apache.rave.model.Authority

    }

    @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));
View Full Code Here

Examples of org.apache.rave.model.Authority

        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

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

Examples of org.apache.rave.model.Authority

* 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

Examples of org.apache.rave.model.Authority

        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

Examples of org.apache.rave.model.Authority

        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

Examples of org.apache.rave.model.Authority

        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

Examples of org.apache.rave.model.Authority

        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

Examples of org.apache.rave.model.Authority

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

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

Examples of org.apache.rave.model.Authority

     */
    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
Copyright © 2018 www.massapi.com. 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.