Package org.apache.rave.portal.model

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


    @Test
    @Rollback(true)
    public void save_cascadeMerge() {
        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


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

        RegionWidget regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        regionWidget.getPreferences().remove(0);

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        RegionWidgetPreference preference = manager.find(JpaRegionWidgetPreference.class, VALID_PREFERENCE_ID);

        assertThat(saved.getPreferences().size(), is(equalTo(0)));
        assertThat(preference, is(nullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void delete_jpaObject() {
        RegionWidget regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(notNullValue()));
        repository.delete(regionWidget);
        regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(nullValue()));
    }
View Full Code Here

    }

    @Test
    @Rollback(true)
    public void delete_implObject() {
        RegionWidget regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(notNullValue()));
        RegionWidgetImpl impl = new RegionWidgetImpl(regionWidget.getId());
        repository.delete(impl);
        regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        assertThat(regionWidget, is(nullValue()));
    }
View Full Code Here

        regionWidget = repository.get(VALID_REGION_WIDGET_ID);
        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();
        return ((JpaRegionWidgetPreference)saved.getPreferences().get(0)).getEntityId();
    }
View Full Code Here

    @Test
    public void render_supported_foo() {
        WidgetImpl w = new WidgetImpl();
        w.setType(SUPPORTED_TYPE_1);

        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidget(w);

        expect(widgetRenderer1.render(rw, context)).andReturn(RENDERED_TYPE_1);
        replayMocks();

        constructFooBarRenderService();
View Full Code Here

    @Test
    public void render_supported_bar() {
        WidgetImpl w = new WidgetImpl();
        w.setType(SUPPORTED_TYPE_2);
        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidget(w);

        expect(widgetRenderer2.render(rw, context)).andReturn(RENDERED_TYPE_2);
        replayMocks();

        constructFooBarRenderService();
View Full Code Here

    @Test(expected = NotSupportedException.class)
    public void render_invalid() {
        WidgetImpl w = new WidgetImpl();
        w.setType("NONE");

        RegionWidget rw = new RegionWidgetImpl();
        rw.setWidget(w);

        replayMocks();

        constructFooBarRenderService();
        service.render(rw, context);
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

    public void save_cascadeMerge() {

        JpaRegion region = new JpaRegion();
        region.setEntityId(1L);
        region.setRegionWidgets(new ArrayList<RegionWidget>());
        RegionWidget regionWidget = new JpaRegionWidget();
        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

TOP

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

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.