Package org.apache.rave.portal.model

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


    }


    @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


        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 setAuthenticatedUser_validRole() {
        final User authUser = new UserImpl(USER_ID);
        final Authority userRole = new AuthorityImpl();
        userRole.setAuthority("admin");
        authUser.addAuthority(userRole);
        expect(userRepository.get(USER_ID)).andReturn(authUser).anyTimes();
        replay(userRepository);

        service.setAuthenticatedUser(USER_ID);
View Full Code Here

    }

    @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

    }

    @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

    }

    @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

        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

    }

    @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

        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

    }

    @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

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.