Package org.apache.rave.portal.model

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


    @Test
    public void save_Valid(){
        PortalPreference item = new PortalPreferenceImpl();
        item.setKey("123");
        PortalPreference fromDb = new MongoDbPortalPreference();
        ((MongoDbPortalPreference)fromDb).setId("123");
        PortalPreference converted = new MongoDbPortalPreference();
        expect(converter.convert(item, PortalPreference.class)).andReturn(converted);
        expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn((MongoDbPortalPreference)fromDb);
        template.save(converted, CollectionNames.PREFERENCE_COLLECTION);
        expectLastCall();
        converter.hydrate(converted, PortalPreference.class);
View Full Code Here


    @Test
    public void save_Null(){
        PortalPreference item = new PortalPreferenceImpl();
        item.setKey("123");
        PortalPreference converted = new MongoDbPortalPreference();
        expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn(null);
        expect(converter.convert(item, PortalPreference.class)).andReturn(converted);
        template.save(converted, PREFERENCE_COLLECTION);
        expectLastCall();
        converter.hydrate(converted, PortalPreference.class);
View Full Code Here

        return PortalPreference.class;
    }

    @Override
    public MongoDbPortalPreference convert(PortalPreference source) {
        MongoDbPortalPreference converted = source instanceof MongoDbPortalPreference ? (MongoDbPortalPreference) source : new MongoDbPortalPreference();
        converted.setKey(source.getKey());
        converted.setValues(source.getValues());
        return converted;
    }
View Full Code Here

    }

    @Override
    public PortalPreference save(PortalPreference item) {
        PortalPreference fromDb = getByKey(item.getKey());
        MongoDbPortalPreference converted = converter.convert(item, PortalPreference.class);
        if(fromDb != null) {
            converted.setId(((MongoDbPortalPreference)fromDb).getId());
        }
        template.save(converted, PREFERENCE_COLLECTION);
        converter.hydrate(converted, PortalPreference.class);
        return converted;
    }
View Full Code Here

    public void convertPreference_valid(){

        PortalPreference pp = new PortalPreferenceImpl();
        pp.setKey("key");
        pp.setValues(Lists.<String>newLinkedList());
        MongoDbPortalPreference converted;
        MongoDbPortalPreference mpp = new MongoDbPortalPreference();
        mpp.setKey("carol");
        mpp.setValues(Lists.<String>newLinkedList());

        converted = converter.convert(pp);

        assertThat(converted.getKey(), is(equalTo("key")));
        assertTrue(converted.getValues().isEmpty());
View Full Code Here

    }

    @Test
    public void hydrate(){
        MongoDbPortalPreference mpp = new MongoDbPortalPreference();
        converter.hydrate(mpp);
        assertNotNull(mpp);
    }
View Full Code Here

    }

    @Override
    public PortalPreference save(PortalPreference item) {
        PortalPreference fromDb = getByKey(item.getKey());
        MongoDbPortalPreference converted = converter.convert(item, PortalPreference.class);
        if(fromDb != null) {
            converted.setId(((MongoDbPortalPreference)fromDb).getId());
        }
        template.save(converted, PREFERENCE_COLLECTION);
        converter.hydrate(converted, PortalPreference.class);
        return converted;
    }
View Full Code Here

    @Test
    public void save_Valid(){
        PortalPreference item = new PortalPreferenceImpl();
        item.setKey("123");
        PortalPreference fromDb = new MongoDbPortalPreference();
        ((MongoDbPortalPreference)fromDb).setId("123");
        PortalPreference converted = new MongoDbPortalPreference();
        expect(converter.convert(item, PortalPreference.class)).andReturn(converted);
        expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn((MongoDbPortalPreference)fromDb);
        template.save(converted, CollectionNames.PREFERENCE_COLLECTION);
        expectLastCall();
        converter.hydrate(converted, PortalPreference.class);
View Full Code Here

    @Test
    public void save_Null(){
        PortalPreference item = new PortalPreferenceImpl();
        item.setKey("123");
        PortalPreference converted = new MongoDbPortalPreference();
        expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn(null);
        expect(converter.convert(item, PortalPreference.class)).andReturn(converted);
        template.save(converted, PREFERENCE_COLLECTION);
        expectLastCall();
        converter.hydrate(converted, PortalPreference.class);
View Full Code Here

    public void convertPreference_valid(){

        PortalPreference pp = new PortalPreferenceImpl();
        pp.setKey("key");
        pp.setValues(Lists.<String>newLinkedList());
        MongoDbPortalPreference converted;
        MongoDbPortalPreference mpp = new MongoDbPortalPreference();
        mpp.setKey("carol");
        mpp.setValues(Lists.<String>newLinkedList());

        converted = converter.convert(pp);

        assertThat(converted.getKey(), is(equalTo("key")));
        assertTrue(converted.getValues().isEmpty());
View Full Code Here

TOP

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

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.