Package org.apache.rave.portal.model

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


        assertThat(region.getRegionWidgets().size(), is(equalTo(2)));
    }

    @Test
    public void getById_invalidId() {
        JpaRegion region = (JpaRegion)repository.get(INVALID_REGION_ID);
        assertThat(region, is(nullValue()));
    }
View Full Code Here


    }

    @Test
    @Rollback(true)
    public void save_newEntity() {
        JpaRegion region = new JpaRegion();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        JpaRegion saved = (JpaRegion)repository.save(region);
        manager.flush();
        assertThat(saved, is(sameInstance(region)));
        assertThat(saved.getEntityId(), is(notNullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_existingEntity() {
        JpaRegion region = new JpaRegion();
        region.setEntityId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        JpaRegion saved = (JpaRegion)repository.save(region);
        manager.flush();
        assertThat(saved, is(not(sameInstance(region))));
        assertThat(saved.getEntityId(), is(equalTo(region.getEntityId())));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        JpaRegion region = new JpaRegion();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget();
        region.getRegionWidgets().add(regionWidget);

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

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

        assertThat(actual, is(sameInstance(regionWidget)));
        assertThat(actual.getId(), is(notNullValue()));
    }
View Full Code Here

    @Test
    @Rollback(true)
    public void save_cascadeMerge() {

        JpaRegion region = new JpaRegion(1L);
        region.setEntityId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        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());
View Full Code Here

    }

    @Test
    @Rollback(true)
    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, id);
View Full Code Here

        return manager.find(JpaRegion.class, Long.parseLong(id));
    }

    @Override
    public Region save(Region item) {
        JpaRegion region = regionConverter.convert(item);
        return saveOrUpdate(region.getEntityId(), manager, region);
    }
View Full Code Here

    @Autowired
    private RegionRepository repository;

    @Test
    public void getById_validId() {
        JpaRegion region = (JpaRegion)repository.get(REGION_ID);
        assertThat(region, is(notNullValue()));
        assertThat(region.getEntityId(), is(equalTo(1L)));
        assertThat(region.getRegionWidgets().size(), is(equalTo(2)));
    }
View Full Code Here

        assertThat(region.getRegionWidgets().size(), is(equalTo(2)));
    }

    @Test
    public void getById_invalidId() {
        JpaRegion region = (JpaRegion)repository.get(INVALID_REGION_ID);
        assertThat(region, is(nullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_newEntity() {
        JpaRegion region = new JpaRegion();
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        JpaRegion saved = (JpaRegion)repository.save(region);
        manager.flush();
        assertThat(saved, is(sameInstance(region)));
        assertThat(saved.getEntityId(), is(notNullValue()));
    }
View Full Code Here

TOP

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

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.