Package org.apache.rave.portal.model

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


        assertTrue(preferences.size() == 2);
    }

    @Test
    public void testGetByKey() {
        PortalPreference preference = repository.getByKey("color");
        assertNotNull(preference);
        assertTrue("Expecting preference with one of the values to be red", preference.getValues().contains("red"));
        assertTrue("Expecting preference with one of the values to be blue", preference.getValues().contains("blue"));
    }
View Full Code Here


        assertTrue("Expecting preference with one of the values to be blue", preference.getValues().contains("blue"));
    }

    @Test
    public void testGetByKey_notExisting() {
        PortalPreference preference = repository.getByKey("foo");
        assertNull(preference);
    }
View Full Code Here

        assertNull(preference);
    }

    @Test
    public void testValuesAreOverwritten() throws Exception {
        PortalPreference preference = repository.getByKey("color");
        List<String> newColors = new ArrayList<String>();
        newColors.add("purple");
        newColors.add("green");
        preference.setValues(newColors);
        final PortalPreference saved = repository.save(preference);
        assertEquals(2, saved.getValues().size());
    }
View Full Code Here

        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

    }

    @Test
    public void get_Valid(){
        String id = "123";
        PortalPreference found = new PortalPreferenceImpl();
        expect(template.findById(id, preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn((PortalPreferenceImpl)found);
        replay(template);

        assertThat(found, is(sameInstance(preferenceRepository.get(id))));
    }
View Full Code Here

        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

        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

        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

     * (non-Javadoc)
     * @see org.apache.rave.portal.service.WidgetResolverService#addWidget(org.apache.rave.portal.model.Widget)
     */
    @Override
    public Widget addWidget(Widget widget) throws Exception{
        PortalPreference status = portalPreferenceService.getPreference(PortalPreferenceKeys.INITIAL_WIDGET_STATUS);
        User user = userService.getAuthenticatedUser();
        widget.setOwnerId(user.getId());
        if (status != null && status.getValue().equals("PUBLISHED")){
            widget.setWidgetStatus(WidgetStatus.PUBLISHED);
        } else {
            widget.setWidgetStatus(WidgetStatus.PREVIEW);
        }
        return widgetService.registerNewWidget(widget);
View Full Code Here

     * (non-Javadoc)
     * @see org.apache.rave.portal.service.RemoteWidgetResolverService#isPublished()
     */
    @Override
    public boolean isPublished() {
        PortalPreference status = portalPreferenceService.getPreference(PortalPreferenceKeys.INITIAL_WIDGET_STATUS);
        if (status != null && status.getValue().equals("PUBLISHED")){
            return true;
        }
        return false;
    }
View Full Code Here

TOP

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

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.