Package org.apache.rave.portal.model

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


    }

    @Test
    public void testNoConversion() {
        JpaRegionWidgetPreference template = new JpaRegionWidgetPreference();
        assertThat(converter.convert(template), is(sameInstance(template)));
    }
View Full Code Here


        RegionWidgetPreference template = new RegionWidgetPreferenceImpl();
        template.setName("TEST_A");
        template.setRegionWidgetId("42");
        template.setValue("TEST_B");

        JpaRegionWidgetPreference jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaRegionWidgetPreference.class)));
        assertThat(jpaTemplate.getName(), is(equalTo(template.getName())));
        assertThat(jpaTemplate.getRegionWidgetId(), is(equalTo(template.getRegionWidgetId())));
        assertThat(jpaTemplate.getValue(), is(equalTo(template.getValue())));
    }
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)));
        JpaRegionWidgetPreference actual = (JpaRegionWidgetPreference)saved.getPreferences().get(0);

        assertThat(actual, is(sameInstance(regionWidgetPreference)));
        assertThat(actual.getEntityId(), is(notNullValue()));
    }
View Full Code Here

    public JpaRegionWidgetPreference convert(RegionWidgetPreference source) {
        return source instanceof JpaRegionWidgetPreference ? (JpaRegionWidgetPreference) source : createEntity(source);
    }

    private JpaRegionWidgetPreference createEntity(RegionWidgetPreference source) {
        JpaRegionWidgetPreference converted = null;
        if (source != null) {
            TypedQuery<JpaRegionWidgetPreference> query = manager.createNamedQuery(JpaRegionWidgetPreference.FIND_BY_REGION_WIDGET_AND_NAME, JpaRegionWidgetPreference.class);
            query.setParameter(JpaRegionWidgetPreference.NAME_PARAM, source.getName());
            query.setParameter(JpaRegionWidgetPreference.REGION_WIDGET_ID, Long.parseLong(source.getRegionWidgetId()));
            converted = getSingleResult(query.getResultList());

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

    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)));
        JpaRegionWidgetPreference actual = (JpaRegionWidgetPreference)saved.getPreferences().get(0);

        assertThat(actual, is(not(sameInstance(regionWidgetPreference))));
        assertThat(actual.getEntityId(), is(equalTo(regionWidgetPreference.getEntityId())));
    }
View Full Code Here

        assertThat(regionWidget, is(nullValue()));
    }

    private long addPreferenceToRegionWidget(Long validRegionWidgetId) {
        RegionWidget regionWidget = repository.get(validRegionWidgetId.toString());
        RegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(null, validRegionWidgetId,
                VALID_PREFERENCE_NAME, VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
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)));
        JpaRegionWidgetPreference actual = (JpaRegionWidgetPreference)saved.getPreferences().get(0);

        assertThat(actual, is(sameInstance(regionWidgetPreference)));
        assertThat(actual.getEntityId(), is(notNullValue()));
    }
View Full Code Here

        long VALID_PREFERENCE_ID = addPreferenceToRegionWidget(VALID_REGION_WIDGET_ID);

        RegionWidget regionWidget = new JpaRegionWidget();
        regionWidget.setId(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)));
        JpaRegionWidgetPreference actual = (JpaRegionWidgetPreference)saved.getPreferences().get(0);

        assertThat(actual, is(not(sameInstance(regionWidgetPreference))));
        assertThat(actual.getEntityId(), is(equalTo(regionWidgetPreference.getEntityId())));
    }
View Full Code Here

        assertThat(regionWidget, is(nullValue()));
    }

    private long addPreferenceToRegionWidget(long validRegionWidgetId) {
        RegionWidget regionWidget = repository.get(validRegionWidgetId);
        RegionWidgetPreference regionWidgetPreference = new JpaRegionWidgetPreference(null, validRegionWidgetId,
                VALID_PREFERENCE_NAME, VALID_PREFERENCE_VALUE);
        regionWidget.getPreferences().add(regionWidgetPreference);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
View Full Code Here

    public JpaRegionWidgetPreference convert(RegionWidgetPreference source) {
        return source instanceof JpaRegionWidgetPreference ? (JpaRegionWidgetPreference) source : createEntity(source);
    }

    private JpaRegionWidgetPreference createEntity(RegionWidgetPreference source) {
        JpaRegionWidgetPreference converted = null;
        if (source != null) {
            TypedQuery<JpaRegionWidgetPreference> query = manager.createNamedQuery(JpaRegionWidgetPreference.FIND_BY_REGION_WIDGET_AND_NAME, JpaRegionWidgetPreference.class);
            query.setParameter(JpaRegionWidgetPreference.NAME_PARAM, source.getName());
            query.setParameter(JpaRegionWidgetPreference.REGION_WIDGET_ID, source.getRegionWidgetId());
            converted = getSingleResult(query.getResultList());

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

TOP

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

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.