Package org.apache.rave.portal.model

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


    @Autowired
    private JpaRegionWidgetConverter regionWidgetConverter;

    @Test
    public void noConversion() {
        RegionWidget rw = new JpaRegionWidget();
        assertThat(regionWidgetConverter.convert(rw), is(sameInstance(rw)));
    }
View Full Code Here


        rw.setPreferences(new ArrayList<RegionWidgetPreference>());
        rw.setRegion(new RegionImpl("1"));
        rw.setRenderPosition("last");
        rw.setWidgetId("1");

        JpaRegionWidget converted = regionWidgetConverter.convert(rw);
        assertThat(converted, is(not(sameInstance(rw))));
        assertThat(converted, is(instanceOf(JpaRegionWidget.class)));
        assertThat(converted.getPreferences(), is(equalTo(rw.getPreferences())));
        assertThat(converted.getEntityId().toString(), is(equalTo(rw.getId())));
        assertThat(converted.getId(), is(equalTo(rw.getId())));
        assertThat(converted.isCollapsed(), is(equalTo(rw.isCollapsed())));
        assertThat(converted.getRenderOrder(), is(equalTo(rw.getRenderOrder())));
        assertThat(converted.isLocked(), is(equalTo(rw.isLocked())));
        assertThat(converted.isHideChrome(), is(equalTo(rw.isHideChrome())));
        assertThat(converted.getRegion(), is(instanceOf(JpaRegion.class)));
        assertThat(converted.getRenderPosition(), is(equalTo(rw.getRenderPosition())));
        assertThat(converted.getWidgetId(), is(instanceOf(String.class)));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_newEntity() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(sameInstance(regionWidget)));
        assertThat(saved.getId(), is(notNullValue()));
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_existingEntity() {
        RegionWidget regionWidget = new JpaRegionWidget(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        assertThat(saved, is(not(sameInstance(regionWidget))));
        assertThat(saved.getId(), is(equalTo(regionWidget.getId())));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        RegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(null, null, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();

        assertThat(saved.getPreferences().size(), is(equalTo(1)));
View Full Code Here

    @Test
    @Rollback(true)
    public void save_cascadeMerge() {
        long VALID_PREFERENCE_ID = addPreferenceToRegionWidget(VALID_REGION_WIDGET_ID);

        RegionWidget regionWidget = new JpaRegionWidget(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        JpaRegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(VALID_PREFERENCE_ID,
                VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME, VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();

        assertThat(saved.getPreferences().size(), is(equalTo(1)));
View Full Code Here

    public JpaRegionWidget convert(RegionWidget source) {
        return source instanceof JpaRegionWidget ? (JpaRegionWidget) source : createEntity(source);
    }

    private JpaRegionWidget createEntity(RegionWidget source) {
        JpaRegionWidget converted = null;
        if (source != null) {
            TypedQuery<JpaRegionWidget> query = manager.createNamedQuery(JpaRegionWidget.FIND_BY_ID, JpaRegionWidget.class);
            query.setParameter(JpaRegionWidget.PARAM_WIDGET_ID, source.getId() == null ? null : Long.parseLong(source.getId()));
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaRegionWidget();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

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

    @Override
    public RegionWidget save(RegionWidget item) {
        JpaRegionWidget region = regionWidgetConverter.convert(item);
        return saveOrUpdate(region.getEntityId(), manager, region);
    }
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();
View Full Code Here

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

TOP

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

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.