Package org.apache.rave.portal.model

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


    }

    @Test
    public void save_cascadeMerge() {

        Region region = new Region();
        region.setId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new RegionWidget();
        regionWidget.setId(1L);
        region.getRegionWidgets().add(regionWidget);

        Region saved = repository.save(region);
        manager.flush();

        assertThat(saved.getRegionWidgets().size(), is(equalTo(1)));
        RegionWidget actual = saved.getRegionWidgets().get(0);

        assertThat(actual, is(not(sameInstance(regionWidget))));
        assertThat(actual.getId(), is(equalTo(1L)));
    }
View Full Code Here


        assertThat(actual.getId(), is(equalTo(1L)));
    }

    @Test
    public void save_cascadeOrphan() {
        Region region = repository.get(1L);
        long id = region.getRegionWidgets().get(0).getId();
        region.getRegionWidgets().remove(0);

        Region saved = repository.save(region);
        manager.flush();
        RegionWidget widget = manager.find(RegionWidget.class, id);

        assertThat(saved.getRegionWidgets().size(), is(equalTo(1)));
        assertThat(widget, is(nullValue()));
    }
View Full Code Here

        replay(userService);
       
        Widget w = new Widget();
        w.setType(Constants.WIDGET_TYPE);
        w.setUrl("http://example.com/widgets/1");
        Region region = new Region(1L);
        RegionWidget rw = new RegionWidget();
        rw.setEntityId(1L);
        rw.setWidget(w);
        rw.setRegion(region);
View Full Code Here

        Widget w = new Widget();
        w.setEntityId(1L);
        w.setType(Constants.WIDGET_TYPE);
        w.setUrl(VALID_GADGET_URL);
        Region region = new Region(1L);
        RegionWidget rw = new RegionWidget();
        rw.setEntityId(1L);
        rw.setCollapsed(VALID_COLLAPSED);
        rw.setWidget(w);
        rw.setRegion(region);
View Full Code Here

    @Test
    public void render_null() {
        Widget w = new Widget();
        w.setType(Constants.WIDGET_TYPE);
        Region region = new Region(1L);
        RegionWidget rw = new RegionWidget();
        rw.setWidget(w);
        rw.setRegion(region);

        final String markup =
View Full Code Here

    }

    private void removeRegion(Page page, Region item) {
        Iterator<Region> iterator = page.getRegions().iterator();
        while(iterator.hasNext()) {
            Region region = iterator.next();
            if(region.getId().equals(item.getId())) {
                iterator.remove();
                return;
            }
        }
    }
View Full Code Here

        return savedWidget;
    }

    private RegionWidget addNewRegionWidget(RegionWidget item) {
        Page page = getPageFromRepository(item);
        Region parent = getRegionById(item.getRegion().getId(), page.getRegions());
        if(parent == null) throw new IllegalStateException("Unable to find parent for page");
        parent.getRegionWidgets().add(item);
        Page saved = template.save(page);
        return getRegionById(parent.getId(), saved.getRegions()).getRegionWidgets().get(parent.getRegionWidgets().size() -1);
    }
View Full Code Here

    @Test
    public void get(){
        String id = "1111L";
        Page page = new PageImpl("1234L");
        List<Region> regions = Lists.newArrayList();
        Region region = new RegionImpl(id);
        regions.add(region);
        page.setRegions(regions);

        expect( template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is(id))))).andReturn(page);
        replay(template);

        Region result = repo.get(id);
        assertNotNull(result);
        assertThat(result, is(equalTo(region)));
        assertThat(result.getId(), equalTo(id));

    }
View Full Code Here

        RegionWidget regionWidget = new JpaRegionWidget(1L);
        region.getRegionWidgets().add(regionWidget);

        System.out.println(region.toString());

        Region saved = repository.save(region);
        manager.flush();

        System.out.println(saved.toString());

        assertThat(saved.getRegionWidgets().size(), is(equalTo(1)));
        RegionWidget actual = saved.getRegionWidgets().get(0);

        assertThat(actual, is(not(sameInstance(regionWidget))));
        assertThat(actual.getId(), is(equalTo("1")));
    }
View Full Code Here

    public void save_cascadeOrphan() {
        JpaRegion region = (JpaRegion)repository.get("1");
        String id = region.getRegionWidgets().get(0).getId();
        region.getRegionWidgets().remove(0);

        Region saved = repository.save(region);
        manager.flush();
        RegionWidget widget = manager.find(JpaRegionWidget.class, Long.parseLong(id));

        assertThat(saved.getRegionWidgets().size(), is(equalTo(1)));
        assertThat(widget, is(nullValue()));
    }
View Full Code Here

TOP

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

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.