Package org.apache.rave.portal.model.impl

Examples of org.apache.rave.portal.model.impl.RegionWidgetImpl


        assertTrue(preferencesHaveValidRegionWidgetId(savedPreferences));
    }

    @Test
    public void saveRegionWidgetPreference() {
        final RegionWidget VALID_REGION_WIDGET = new RegionWidgetImpl(VALID_REGION_WIDGET_ID);
        VALID_REGION_WIDGET.setPreferences(getTestExistingRegionWidgetPreferences());

        expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(VALID_REGION_WIDGET).anyTimes();
        expect(regionWidgetRepository.save(VALID_REGION_WIDGET)).andReturn(VALID_REGION_WIDGET).anyTimes();
        replay(regionWidgetRepository);

        //Add and update a preference.
        RegionWidgetPreference newPreference = new RegionWidgetPreferenceImpl(null, "age", "30");
        RegionWidgetPreference savedNewPreference = regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, newPreference);
        RegionWidgetPreference updatedPreference = new RegionWidgetPreferenceImpl(null, "color", "purple");
        RegionWidgetPreference savedUpdatedPreference = regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, updatedPreference);

        //Make sure the new and updated preference got mixed in properly with the existing preferences.
        List<RegionWidgetPreference> existingPreferences = getTestExistingRegionWidgetPreferences();
        existingPreferences.add(savedNewPreference);
        existingPreferences.get(0).setValue("purple");
        assertTrue(preferenceCollectionsMatch(existingPreferences, VALID_REGION_WIDGET.getPreferences()));
        assertTrue(preferencesHaveValidRegionWidgetId(VALID_REGION_WIDGET.getPreferences()));
    }
View Full Code Here


    public void render_supported_foo() {
        WidgetImpl w = new WidgetImpl();
        w.setId("1");
        w.setType(SUPPORTED_TYPE_1);

        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidgetId(w.getId());

        RegionWidgetWrapper wrapper = new RegionWidgetWrapper(w, rw);

        expect(widgetRenderer1.render(wrapper, context)).andReturn(RENDERED_TYPE_1);
        expect(widgetRepository.get("1")).andReturn(w);
View Full Code Here

    @Test
    public void render_supported_bar() {
        WidgetImpl w = new WidgetImpl();
        w.setId("1");
        w.setType(SUPPORTED_TYPE_2);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidgetId(w.getId());

        RegionWidgetWrapper wrapper = new RegionWidgetWrapper(w, rw);

        expect(widgetRenderer2.render(wrapper, context)).andReturn(RENDERED_TYPE_2);
        expect(widgetRepository.get("1")).andReturn(w);
View Full Code Here

    public void render_invalid() {
        WidgetImpl w = new WidgetImpl();
        w.setId("1");
        w.setType("NONE");

        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidgetId(w.getId());

        RegionWidgetWrapper wrapper = new RegionWidgetWrapper(w, rw);

        expect(widgetRepository.get("1")).andReturn(w);
View Full Code Here

     * @return List of RegionWidget
     */
    private List<RegionWidget> convertWidgets(List<PageTemplateWidget> pageTemplateWidgets, Region region){
        List<RegionWidget> widgets = new ArrayList<RegionWidget>();
        for (PageTemplateWidget ptw : pageTemplateWidgets){
            RegionWidget regionWidget = new RegionWidgetImpl();
            regionWidget.setRegion(region);
            regionWidget.setCollapsed(false);
            regionWidget.setLocked(ptw.isLocked());
            regionWidget.setHideChrome(ptw.isHideChrome());
            regionWidget.setRenderOrder((int) ptw.getRenderSeq());
            regionWidget.setWidgetId(ptw.getWidgetId());
            widgets.add(regionWidget);
        }
        return widgets;
    }
View Full Code Here

    @Test
    public void get_DifferentId() {
        String id = "234";
        Page page = new PageImpl();
        Region region = new RegionImpl();
        RegionWidgetImpl widget = new RegionWidgetImpl();
        widget.setId("123");
        page.setRegions(Arrays.asList(region));
        region.setPage(page);
        region.setRegionWidgets(Arrays.<RegionWidget>asList(widget));
        widget.setRegion(region);

        expect(template.findOne(new Query(where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))))).andReturn(page);
        replay(template);
        RegionWidget result = widgetRepository.get(id);
        assertNull(result);
View Full Code Here

    public void get_Valid() {
        String id = "123";
        Page found = new MongoDbPage();
        Region region = new RegionImpl();
        found.setRegions(Arrays.asList(region));
        RegionWidgetImpl widget = new RegionWidgetImpl();
        region.setRegionWidgets(Arrays.<RegionWidget>asList(widget));
        widget.setId("123");
        expect(template.findOne(new Query(where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))))).andReturn(found);
        replay(template);

        assertThat(widget, is(sameInstance(widgetRepository.get(id))));
    }
View Full Code Here

        assertNull(widgetRepository.get(id));
    }

    @Test
    public void save_Id_Valid() {
        RegionWidgetImpl widget = new RegionWidgetImpl();
        RegionWidgetImpl replaced = new RegionWidgetImpl();

        String id = "123";
        widget.setId(id);
        replaced.setId(id);
        replaced.setCollapsed(true);
        Page parent = new PageImpl();
        Region region = new RegionImpl();
        List<Region> regions = new ArrayList<Region>();
        regions.add(region);
        List<RegionWidget> regionWidgets = new ArrayList<RegionWidget>();
View Full Code Here

        assertThat(savedWidget, is(sameInstance((RegionWidget)widget)));
    }

    @Test
    public void save_Id_Valid_Page_Null() {
        RegionWidgetImpl item = new RegionWidgetImpl();
        String id = "123";
        item.setId(id);
        Page page = new PageImpl();
        page.setRegions(new ArrayList<Region>());

        expect(template.findOne(new Query(where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))))).andReturn(page);
        replay(template);
View Full Code Here

        widgetRepository.save(item);
    }

    @Test
    public void save_Id_Null_Page_Valid_Regions_Valid() {
        RegionWidgetImpl widget = new RegionWidgetImpl();

        RegionImpl region = new RegionImpl();
        Page page = new PageImpl();
        String id = "321";
        page.setId(id);
        List<Region> regions = new ArrayList<Region>();
        regions.add(region);
        page.setRegions(regions);
        region.setPage(page);
        region.setId(id);
        widget.setRegion(region);
        List<RegionWidget> widgets = new ArrayList<RegionWidget>();
        widgets.add(widget);
        region.setRegionWidgets(widgets);

        expect(template.get(id)).andReturn(page);
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.impl.RegionWidgetImpl

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.