Examples of Authority


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

Examples of org.apache.rave.model.Authority

    }

    @Test
    public void save_validNew(){
        Authority returnedAuth;
        Authority savedAuth = new MongoDbAuthority();
        savedAuth.setAuthority("test");

        template.save(isA(Authority.class), eq(AUTHORITY_COLLECTION));
        expectLastCall();
        expect(template.findOne(query(where("authority").is("test")), CLASS, AUTHORITY_COLLECTION)).andReturn(null);
        replay(template);
View Full Code Here

Examples of org.apache.rave.model.Authority

        verify(template);
    }

    @Test
    public void save_valid(){
        Authority savedAuth = new MongoDbAuthority();
        Authority returnedAuth;
        savedAuth.setAuthority("test");

        expect(template.findOne(query(where("authority").is("test")), CLASS, AUTHORITY_COLLECTION)).andReturn((MongoDbAuthority)savedAuth);
        template.save(isA(Authority.class), eq(AUTHORITY_COLLECTION));
        expectLastCall();

        replay(template);

        returnedAuth = repo.save(savedAuth);
        assertThat(savedAuth.isDefaultForNewUser(), is(equalTo(returnedAuth.isDefaultForNewUser())));
        assertNotNull(template);
        assertThat(savedAuth, is(sameInstance(returnedAuth)));
        verify(template);

    }
View Full Code Here

Examples of org.apache.rave.model.Authority

    }

    @Test
    public void delete(){
        Authority deleted = new MongoDbAuthority();
        deleted.setAuthority("deleted");

        template.remove(isA(Authority.class), eq(AUTHORITY_COLLECTION));
        expectLastCall();
        expect(template.findOne(query(where("authority").is("deleted")), CLASS, AUTHORITY_COLLECTION)).andReturn((MongoDbAuthority)deleted);
        replay(template);
View Full Code Here

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

Examples of org.apache.rave.model.Authority


    @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

Examples of org.apache.rave.model.Authority

    }

    @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

Examples of org.apache.rave.model.Authority


    @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

Examples of org.apache.rave.model.Authority

    }

    @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

Examples of org.apache.rave.model.Authority

    }

    @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 JpaUser();
        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
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.