Package org.apache.rave.portal.model

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


    }

    @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

        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

        return Authority.class;
    }

    @Override
    public MongoDbAuthority convert(Authority source) {
        MongoDbAuthority converted = source instanceof MongoDbAuthority ? (MongoDbAuthority) source : new MongoDbAuthority();
        converted.setAuthority(source.getAuthority());
        converted.setDefaultForNewUser(source.isDefaultForNewUser());
        return converted;
    }
View Full Code Here

        authorityConverter = new MongoDbAuthorityConverter();
    }

    @Test
    public void hydrate_Valid(){
        MongoDbAuthority authority = new MongoDbAuthority();
        authorityConverter.hydrate(authority);
        assertNotNull(authority);
    }
View Full Code Here

    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

TOP

Related Classes of org.apache.rave.portal.model.MongoDbAuthority

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.