Package org.apache.rave.portal.model

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


    }

    @Test
    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(getQuery(id))).andReturn(found);
        replay(template);
View Full Code Here


    }

    @Test
    public void get_Null() {
        String id = "321";
        Page found = new MongoDbPage();
        found.setRegions(new ArrayList<Region>());
        expect(template.findOne(getQuery(id))).andReturn(found);
        replay(template);
        assertNull(widgetRepository.get(id));
    }
View Full Code Here

    }

    @Test
    public void convertPage_valid() {

        MongoDbPage results;
        PageUser pageUser = new PageUserImpl(USER1ID);
        Page sourcePage = new PageImpl();
        pageUser.setUserId(USER2ID);

        List<PageUser> pageMembers = Lists.newArrayList();
        pageMembers.add(pageUser);
        sourcePage.setMembers(pageMembers);

        Region region = new RegionImpl();
        region.setRegionWidgets(Lists.<RegionWidget>newLinkedList());
        RegionWidgetImpl rw = new RegionWidgetImpl();
        rw.setId("2222");
        rw.setWidgetId("3333");
        rw.setPreferences(Lists.<RegionWidgetPreference>newLinkedList());

        region.getRegionWidgets().add(rw);
        sourcePage.setRegions(Lists.<Region>newLinkedList());
        sourcePage.getRegions().add(region);

        Page parentPage = new PageImpl();
        PageLayout pagelayout = new PageLayoutImpl();
        pagelayout.setCode("asdf");

        sourcePage.setId(PAGEID);
        sourcePage.setOwnerId(USER2ID);
        sourcePage.setPageLayout(pagelayout);
        sourcePage.setName("Carol");
        sourcePage.setParentPage(parentPage);
        sourcePage.setPageType(PageType.USER);

        results = converter.convert(sourcePage);

        assertThat(results.getName(), is(equalTo("Carol")));
        assertThat(results.getPageType(), is(PageType.USER));
        assertThat(results.getRegions().size(), is(1));
        assertNotNull(results.getRegions().get(0).getId());
        assertNull(results.getRegions().get(0).getPage());
        assertThat(results.getPageLayout(), is(nullValue(PageLayout.class)));
        assertThat(results.getParentPage(), is(nullValue()));
        assertThat(results.getMembers().size(), is(1));
        assertThat(results.getRegions().get(0).getRegionWidgets().get(0), is(instanceOf(RegionWidgetImpl.class)));
        assertNotNull(results.getRegions().get(0).getRegionWidgets().get(0).getId());
        assertNull(results.getRegions().get(0).getRegionWidgets().get(0).getRegion());
        assertThat(results.getRegions().get(0).getRegionWidgets().get(0).getPreferences(), is(equalTo(sourcePage.getRegions().get(0).getRegionWidgets().get(0).getPreferences())));

    }//end convert page test
View Full Code Here

    }//end convert page test

    @Test
    public void convertPage_Id_Null(){
        Page sourcePage = new MongoDbPage();
        RegionImpl region = new RegionImpl();
        region.setId("123");
        sourcePage.setRegions(Arrays.<Region>asList(region));
        sourcePage.setPageLayout(new PageLayoutImpl());
        sourcePage.setOwnerId(USER1ID);
        sourcePage.setMembers(new ArrayList<PageUser>());


        Page subPage = new MongoDbPage();
        List<Page> subPages = Arrays.asList(subPage);
        subPage.setPageLayout(new PageLayoutImpl());
        subPage.setOwnerId(USER1ID);
        subPage.setId("321");
        subPage.setMembers(new ArrayList<PageUser>());
        subPage.setRegions(new ArrayList<Region>());
        sourcePage.setSubPages(subPages);


        MongoDbPage converted = converter.convert(sourcePage);

        assertTrue(converted.getSubPages().get(0).getId().equals(sourcePage.getSubPages().get(0).getId()));
        assertTrue(converted.getRegions().get(0).equals(region));

    }
View Full Code Here

    }

    @Test
    public void hydratePage_valid() {

        MongoDbPage page = new MongoDbPage();
        page.setRegions(Lists.<Region>newLinkedList());
        Region region1 = new RegionImpl();
        Region region2 = new RegionImpl();

        region1.setRegionWidgets(Lists.<RegionWidget>newLinkedList());
        region2.setRegionWidgets(Lists.<RegionWidget>newLinkedList());
        RegionWidget rw1 = new RegionWidgetImpl();
        region1.getRegionWidgets().add(rw1);

        RegionWidget rw2 = new RegionWidgetImpl();
        region2.getRegionWidgets().add(rw2);

        page.getRegions().add(region1);
        page.getRegions().add(region2);

        page.setMembers(Lists.<PageUser>newLinkedList());
        PageUserImpl member1 = new PageUserImpl();
        PageUser member2 = new PageUserImpl();
        page.getMembers().add(member1);
        page.getMembers().add(member2);

        Region subRegion = new RegionImpl();
        subRegion.setRegionWidgets(Lists.<RegionWidget>newLinkedList());
        RegionWidget subRegionWidget = new RegionWidgetImpl();
        subRegion.getRegionWidgets().add(subRegionWidget);

        page.setSubPages(Lists.<Page>newLinkedList());
        MongoDbPage subPage1 = new MongoDbPage();
        PageUserImpl subMember = new PageUserImpl();
        subPage1.setMembers(Lists.<PageUser>newLinkedList());
        subPage1.setRegions(Lists.<Region>newLinkedList());
        subPage1.getMembers().add(subMember);
        subPage1.getRegions().add(subRegion);
        Page subPage2 = new PageImpl();
        subPage2.setMembers(Lists.<PageUser>newLinkedList());
        subPage2.setRegions(Lists.<Region>newLinkedList());
        page.getSubPages().add(subPage1);
        page.getSubPages().add(subPage2);

        PageLayout pageLayout = new PageLayoutImpl();
        pageLayout.setCode("asdf");
        page.setPageLayoutCode(pageLayout.getCode());

        expect(pageLayoutRepository.getByPageLayoutCode(page.getPageLayoutCode())).andReturn(pageLayout);
        replay(pageLayoutRepository);

        converter.hydrate(page);
        assertThat(page.getPageLayout(), is(sameInstance(pageLayout)));
        assertThat(page.getMembers().get(0), is(instanceOf(PageUserImpl.class)));
        assertThat((MongoDbPage)region1.getPage(), is(sameInstance(page)));
        assertThat((MongoDbPage)subPage1.getParentPage(), is(sameInstance(page)));
        assertThat((MongoDbPage)subPage2.getParentPage(), is(sameInstance(page)));
        assertThat(page.getRegions().get(0).getRegionWidgets().get(0), is(sameInstance(rw1)));

    }//end hydratePage_valid
View Full Code Here

    }

    @Test
    public void hydratePage_null() {
        MongoDbPage page = null;
        converter.hydrate(page);

        assertThat(true, is(true));
    }
View Full Code Here

    }

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

    }

    @Test
    public void get_Null() {
        String id = "321";
        Page found = new MongoDbPage();
        found.setRegions(new ArrayList<Region>());
        expect(template.findOne(new Query(where("regions").elemMatch(where("regionWidgets").elemMatch(where("_id").is(id)))))).andReturn(found);
        replay(template);
        assertNull(widgetRepository.get(id));
    }
View Full Code Here

    }

    @Test
    public void convertPage_valid() {

        MongoDbPage results;
        PageUser pageUser = new PageUserImpl(USER1ID);
        Page sourcePage = new PageImpl();
        pageUser.setUserId(USER2ID);

        List<PageUser> pageMembers = Lists.newArrayList();
        pageMembers.add(pageUser);
        sourcePage.setMembers(pageMembers);

        Region region = new RegionImpl();
        region.setRegionWidgets(Lists.<RegionWidget>newLinkedList());
        RegionWidgetImpl rw = new RegionWidgetImpl();
        rw.setId("2222");
        rw.setWidgetId("3333");
        rw.setPreferences(Lists.<RegionWidgetPreference>newLinkedList());

        region.getRegionWidgets().add(rw);
        sourcePage.setRegions(Lists.<Region>newLinkedList());
        sourcePage.getRegions().add(region);

        Page parentPage = new PageImpl();
        PageLayout pagelayout = new PageLayoutImpl();
        pagelayout.setCode("asdf");

        sourcePage.setId(PAGEID);
        sourcePage.setOwnerId(USER2ID);
        sourcePage.setPageLayout(pagelayout);
        sourcePage.setName("Carol");
        sourcePage.setParentPage(parentPage);
        sourcePage.setPageType(PageType.USER);

        results = converter.convert(sourcePage);

        assertThat(results.getName(), is(equalTo("Carol")));
        assertThat(results.getPageType(), is(PageType.USER));
        assertThat(results.getRegions().size(), is(1));
        assertNotNull(results.getRegions().get(0).getId());
        assertNull(results.getRegions().get(0).getPage());
        assertThat(results.getPageLayout(), is(nullValue(PageLayout.class)));
        assertThat(results.getParentPage(), is(nullValue()));
        assertThat(results.getMembers().size(), is(1));
        assertThat(results.getRegions().get(0).getRegionWidgets().get(0), is(instanceOf(RegionWidgetImpl.class)));
        assertNotNull(results.getRegions().get(0).getRegionWidgets().get(0).getId());
        assertNull(results.getRegions().get(0).getRegionWidgets().get(0).getRegion());
        assertThat(results.getRegions().get(0).getRegionWidgets().get(0).getPreferences(), is(equalTo(sourcePage.getRegions().get(0).getRegionWidgets().get(0).getPreferences())));

    }//end convert page test
View Full Code Here

    }//end convert page test

    @Test
    public void convertPage_Id_Null(){
        Page sourcePage = new MongoDbPage();
        RegionImpl region = new RegionImpl();
        region.setId("123");
        sourcePage.setRegions(Arrays.<Region>asList(region));
        sourcePage.setPageLayout(new PageLayoutImpl());
        sourcePage.setOwnerId(USER1ID);
        sourcePage.setMembers(new ArrayList<PageUser>());


        Page subPage = new MongoDbPage();
        List<Page> subPages = Arrays.asList(subPage);
        subPage.setPageLayout(new PageLayoutImpl());
        subPage.setOwnerId(USER1ID);
        subPage.setId("321");
        subPage.setMembers(new ArrayList<PageUser>());
        subPage.setRegions(new ArrayList<Region>());
        sourcePage.setSubPages(subPages);


        MongoDbPage converted = converter.convert(sourcePage);

        assertTrue(converted.getSubPages().get(0).getId().equals(sourcePage.getSubPages().get(0).getId()));
        assertTrue(converted.getRegions().get(0).equals(region));

    }
View Full Code Here

TOP

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

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.