Package org.apache.rave.portal.model

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


        verify(template);
    }

    @Test
    public void getByAuthority(){
        Authority authority = new MongoDbAuthority();
        authority.setAuthority("test");
        Authority result;
        template.save(authority, AUTHORITY_COLLECTION);

        expect(template.findOne(query(where("authority").is("test")), CLASS, AUTHORITY_COLLECTION)).andReturn((MongoDbAuthority)authority);
        replay(template);
View Full Code Here



    @Test
    public void getAll(){
        List<Authority> allAuth = Lists.newLinkedList();
        Authority authority = new MongoDbAuthority();
        authority.setAuthority("test");
        allAuth.add(authority);

        expect(CollectionUtils.<Authority>toBaseTypedList(template.findAll(CLASS, AUTHORITY_COLLECTION))).andReturn(allAuth);
        replay(template);
View Full Code Here

    }

    @Test
    public void getAllDefault(){
        List<Authority> allDefaultAuth = Lists.newLinkedList();
        Authority authority = new MongoDbAuthority();
        authority.setAuthority("test");
        authority.setDefaultForNewUser(true);
        allDefaultAuth.add(authority);

        expect(CollectionUtils.<Authority>toBaseTypedList(template.find(query(where("defaultForNewUser").is(true)), CLASS, AUTHORITY_COLLECTION))).andReturn(allDefaultAuth);
        replay(template);
View Full Code Here


    @Test
    public void getAllDefault_false(){
        List<Authority> allDefaultAuth = Lists.newLinkedList();
        Authority authority = new MongoDbAuthority();
        authority.setDefaultForNewUser(false);
        allDefaultAuth.add(authority);

        expect(CollectionUtils.<Authority>toBaseTypedList(template.find(query(where("defaultForNewUser").is(true)), CLASS, AUTHORITY_COLLECTION))).andReturn(null);
        replay(template);
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

        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.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.