Examples of PortalPreference


Examples of org.apache.rave.model.PortalPreference

        assertThat(found, is(sameInstance(preferenceRepository.get(id))));
    }

    @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);
        expectLastCall();
        replay(template, converter);

        PortalPreference result = preferenceRepository.save(item);
        assertNotNull(((MongoDbPortalPreference) converted).getId());
        assertThat(result, is(sameInstance(converted)));
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        assertThat(result, is(sameInstance(converted)));
    }

    @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);
        expectLastCall();
        replay(template, converter);

        PortalPreference result = preferenceRepository.save(item);
        assertThat(result, is(sameInstance(converted)));
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        assertThat(result, is(sameInstance(converted)));
    }

    @Test
    public void delete_Valid(){
        PortalPreference item = new PortalPreferenceImpl();
        item.setKey("123");
        PortalPreference found = new PortalPreferenceImpl();
        expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn((PortalPreferenceImpl)found);
        template.remove(found, CollectionNames.PREFERENCE_COLLECTION);
        expectLastCall();
        replay(template);
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        assertEquals(VALUES, preference.getValues());
    }

    @Test
    public void singleValuePreference() throws Exception {
        PortalPreference preference = new JpaPortalPreference(KEY, "bar");
        assertEquals(KEY, preference.getKey());
        assertEquals("bar", preference.getValue());
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        assertEquals("bar", preference.getValue());
    }

    @Test
    public void testGetValues() throws Exception {
        PortalPreference preference = new JpaPortalPreference(KEY, VALUES);
        assertEquals(KEY, preference.getKey());
        assertEquals(VALUES, preference.getValues());
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        assertEquals(VALUES, preference.getValues());
    }

    @Test
    public void testSetValues() throws Exception {
        PortalPreference preference = new JpaPortalPreference(KEY, VALUES);
        assertEquals(KEY, preference.getKey());
        assertEquals(VALUES, preference.getValues());
        preference.setValue("tree");
        assertEquals("tree", preference.getValue());
        assertEquals(1, preference.getValues().size());
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

    }


    @Test(expected = NotSupportedException.class)
    public void getValueFailsForMultiValue() {
        PortalPreference preference = new JpaPortalPreference(KEY, VALUES);
        preference.getValue();
        assertFalse("Expected exception", true);

    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        return template.findById(id, CLASS, PREFERENCE_COLLECTION);
    }

    @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);
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

        }

    }

    public int getPageSize() {
        final PortalPreference pageSizePref = preferenceService.getPreference(PortalPreferenceKeys.PAGE_SIZE);
        if (pageSizePref == null) {
            return DEFAULT_PAGE_SIZE;
        }
        try {
            return Integer.parseInt(pageSizePref.getValue());
        } catch (NumberFormatException e) {
            return DEFAULT_PAGE_SIZE;
        }
    }
View Full Code Here

Examples of org.apache.rave.model.PortalPreference

    private String finalizeNewWidget(WidgetImpl widget, User user, String referringPageId){
        /*
         * By default, a new widget has a status of "PREVIEW", however this can be overridden in portal preferences,
         * skipping the need for an admin to approve a new widget.
         */
        PortalPreference status = preferenceService.getPreference(PortalPreferenceKeys.INITIAL_WIDGET_STATUS);
        if (status != null && status.getValue().equals("PUBLISHED")){
      widget.setWidgetStatus(WidgetStatus.PUBLISHED);
    } else {
          widget.setWidgetStatus(WidgetStatus.PREVIEW);
    }
       
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.