Package org.apache.rave.model

Examples of org.apache.rave.model.Authority


        assertThat(converter.convert(template), is(sameInstance(template)));
    }

    @Test
    public void nullConversion() {
        Authority template = null;
        assertThat(converter.convert(template), is(nullValue()));
    }
View Full Code Here


    }


    @Test
    public void convertValid() {
        Authority template = new AuthorityImpl();
        template.setAuthority("FOO");
        template.setDefaultForNewUser(true);
        template.addUser(new UserImpl("42"));

        JpaAuthority jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaAuthority.class)));
        assertThat(jpaTemplate.getAuthority(), is(equalTo(template.getAuthority())));
        assertThat(jpaTemplate.isDefaultForNewUser(), is(equalTo(template.isDefaultForNewUser())));
        assertThat(jpaTemplate.getUsers().iterator().next().getId(), is(equalTo(template.getUsers().iterator().next().getId())));

    }
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

        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

        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

    }

    @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

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.