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

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


        final String PAGE_NAME = "my new page";
        final String PARENT_PAGE_NAME = "my parent page";
        final Long EXPECTED_RENDER_SEQUENCE = 1L;
        final Long EXPECTED_PARENT_RENDER_SEQUENCE = 1L;

        Page expectedPage = new PageImpl();
        expectedPage.setName(PAGE_NAME);
        expectedPage.setOwnerId(user.getId());
        expectedPage.setPageLayout(pageLayout);
        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));

        Page parentPage = new PageImpl();
        parentPage.setName(PARENT_PAGE_NAME);
        parentPage.setOwnerId(user.getId());
        parentPage.setPageLayout(pageLayout);

        parentPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));

        expect(userService.getAuthenticatedUser()).andReturn(user);
        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
        replay(userService, pageLayoutRepository,  pageRepository);

        Page newPage = pageService.addNewSubPage(PAGE_NAME, PAGE_LAYOUT_CODE, parentPage);
        assertThat(newPage.getMembers().get(0).getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
        assertThat(newPage.getName(), is(PAGE_NAME));
        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
        assertThat(newPage.getPageType(), is(PageType.SUB_PAGE));
        assertThat(newPage.getParentPage(), is(parentPage));
        assertTrue(parentPage.getSubPages().contains(newPage));

        verify(userService, pageLayoutRepository,  pageRepository);
    }
View Full Code Here


    public void addNewSubPage_existingPages() {
        final String PAGE_NAME = "my new page";
        final String PARENT_PAGE_NAME = "my parent page";
        final Long EXPECTED_RENDER_SEQUENCE = 2L;
        List<Page> existingPages = new ArrayList<Page>();
        existingPages.add(new PageImpl());

        Page expectedPage = new PageImpl();
        expectedPage.setName(PAGE_NAME);
        expectedPage.setOwnerId(user.getId());
        expectedPage.setPageLayout(pageLayout);
        expectedPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));

        Page parentPage = new PageImpl();
        parentPage.setName(PARENT_PAGE_NAME);
        parentPage.setOwnerId(user.getId());
        parentPage.setPageLayout(pageLayout);
        parentPage.setRegions(createEmptyRegionList(pageLayout.getNumberOfRegions()));
        parentPage.setSubPages(existingPages);

        expect(userService.getAuthenticatedUser()).andReturn(user);
        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
        replay(userService, pageLayoutRepository,  pageRepository);

        Page newPage = pageService.addNewSubPage(PAGE_NAME, PAGE_LAYOUT_CODE, parentPage);
        assertThat(newPage.getMembers().get(0).getRenderSequence(), is(EXPECTED_RENDER_SEQUENCE));
        assertThat(newPage.getName(), is(PAGE_NAME));
        assertThat(newPage.getRegions().size(), is(pageLayout.getNumberOfRegions().intValue()));
        assertThat(newPage.getPageType(), is(PageType.SUB_PAGE));
        assertThat(newPage.getParentPage(), is(parentPage));
        assertTrue(parentPage.getSubPages().contains(newPage));

        verify(userService, pageLayoutRepository,  pageRepository);
    }
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(getQuery(id))).andReturn(page);
View Full Code Here

        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>();
        regionWidgets.add(replaced);
        parent.setRegions(regions);
        region.setRegionWidgets(regionWidgets);

        expect(template.findOne(getQuery(id))).andReturn(parent);
        expect(template.save(parent)).andReturn(parent);
        replay(template);
View Full Code Here

    @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(getQuery(id))).andReturn(page);
        replay(template);

        thrown.expect(IllegalStateException.class);
View Full Code Here

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

    @Test
    public void save_Id_Null_Page_Valid_Regions_Valid_Diff_Id() {
        RegionWidget item = new RegionWidgetImpl();
        RegionImpl region = new RegionImpl();
        item.setRegion(region);
        Page item_Page = new PageImpl();
        region.setPage(item_Page);
        item_Page.setId("3333");
        region.setId("2222");

        Page page = new PageImpl();
        ArrayList<Region> regions = new ArrayList<Region>();
        regions.add(new RegionImpl());
        page.setRegions(regions);
        expect(template.get(item.getRegion().getPage().getId())).andReturn(page);
        replay(template);

        thrown.expect(IllegalStateException.class);
        thrown.expectMessage("Unable to find parent for page");
View Full Code Here

    @Test
    public void save_Id_Null_Page_Null_Region_Valid_Page_Valid_Id_Null() {
        RegionWidget widget = new RegionWidgetImpl();
        Region region = new RegionImpl();
        widget.setRegion(region);
        Page page = new PageImpl();
        region.setPage(page);

        thrown.expect(IllegalStateException.class);
        thrown.expectMessage("Unable to find page for region");
View Full Code Here

    public void save_Id_Null_Page_Valid_Region_Null() {
        RegionWidget item = new RegionWidgetImpl();
        Region region = new RegionImpl();
        item.setRegion(region);
        String id = "123";
        Page page = new PageImpl();
        region.setPage(page);
        page.setId(id);
        page.setRegions(new ArrayList<Region>());

        thrown.expect(IllegalStateException.class);
        thrown.expectMessage("Unable to find parent for page");

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

    @Test
    public void delete_Valid() {
        RegionWidgetImpl widget = new RegionWidgetImpl();
        String id = "123";
        widget.setId(id);
        Page found = new PageImpl();
        Region region = new RegionImpl();
        List<RegionWidget> regionWidgets = new ArrayList<RegionWidget>();
        regionWidgets.add(widget);
        List<Region> regions = new ArrayList<Region>();
        regions.add(region);
        found.setRegions(regions);
        region.setRegionWidgets(regionWidgets);

        expect(template.findOne(getQuery(id))).andReturn(found);
        expect(template.save(found)).andReturn(null);
        replay(template);
View Full Code Here

TOP

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

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.