Package org.apache.rave.portal.model

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


    }

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

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


    }

    @Test
    @Rollback(true)
    public void save_cascadePersist() {
        RegionWidget regionWidget = new RegionWidget();
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        RegionWidgetPreference regionWidgetPreference = new RegionWidgetPreference(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)));
        RegionWidgetPreference actual = saved.getPreferences().get(0);

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

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

        RegionWidget regionWidget = new RegionWidget();
        regionWidget.setEntityId(VALID_REGION_WIDGET_ID);
        regionWidget.setPreferences(new ArrayList<RegionWidgetPreference>());
        RegionWidgetPreference regionWidgetPreference = new RegionWidgetPreference(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)));
        RegionWidgetPreference actual = 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(RegionWidgetPreference.class, VALID_PREFERENCE_ID);

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

        assertThat(saved.getPreferences().size(), is(equalTo(0)));
        assertThat(preference, is(nullValue()));
    }

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

        RegionWidget saved = repository.save(regionWidget);
        manager.flush();
        return saved.getPreferences().get(0).getEntityId();
    }
View Full Code Here

        regionWidgetService = new DefaultRegionWidgetService(regionWidgetRepository);
    }

    @Test
    public void getRegionWidget_validId() {
        final RegionWidget VALID_REGION_WIDGET = new RegionWidget(VALID_REGION_WIDGET_ID);

        expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(VALID_REGION_WIDGET);
        replay(regionWidgetRepository);

        assertThat(regionWidgetService.getRegionWidget(VALID_REGION_WIDGET_ID), sameInstance(VALID_REGION_WIDGET));
View Full Code Here

        assertThat(regionWidgetService.getRegionWidget(INVALID_REGION_WIDGET_ID), is(nullValue()));
    }

    @Test
    public void saveRegionWidget() {
        final RegionWidget VALID_REGION_WIDGET = new RegionWidget(VALID_REGION_WIDGET_ID);

        expect(regionWidgetRepository.save(VALID_REGION_WIDGET)).andReturn(VALID_REGION_WIDGET);
        replay(regionWidgetRepository);

        assertThat(regionWidgetService.saveRegionWidget(VALID_REGION_WIDGET), sameInstance(VALID_REGION_WIDGET));
View Full Code Here

        assertThat(regionWidgetService.saveRegionWidget(VALID_REGION_WIDGET), sameInstance(VALID_REGION_WIDGET));
    }

    @Test
    public void saveRegionWidgetPreferences() {
        final RegionWidget VALID_REGION_WIDGET = new RegionWidget(VALID_REGION_WIDGET_ID);
        VALID_REGION_WIDGET.setPreferences(getTestExistingRegionWidgetPreferences());

        expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(VALID_REGION_WIDGET);
        expect(regionWidgetRepository.save(VALID_REGION_WIDGET)).andReturn(VALID_REGION_WIDGET);
        replay(regionWidgetRepository);
View Full Code Here

        assertTrue(preferencesHaveValidRegionWidgetId(savedPreferences));
    }

    @Test
    public void saveRegionWidgetPreference() {
        final RegionWidget VALID_REGION_WIDGET = new RegionWidget(VALID_REGION_WIDGET_ID);
        VALID_REGION_WIDGET.setPreferences(getTestExistingRegionWidgetPreferences());

        expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(VALID_REGION_WIDGET).anyTimes();
        expect(regionWidgetRepository.save(VALID_REGION_WIDGET)).andReturn(VALID_REGION_WIDGET).anyTimes();
        replay(regionWidgetRepository);

        //Add and update a preference.
        RegionWidgetPreference newPreference = new RegionWidgetPreference(null, null, "age", "30");
        RegionWidgetPreference savedNewPreference = regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, newPreference);
        RegionWidgetPreference updatedPreference = new RegionWidgetPreference(null, null, "color", "purple");
        RegionWidgetPreference savedUpdatedPreference = regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, updatedPreference);

        //Make sure the new and updated preference got mixed in properly with the existing preferences.
        List<RegionWidgetPreference> existingPreferences = getTestExistingRegionWidgetPreferences();
        existingPreferences.add(savedNewPreference);
        existingPreferences.get(0).setValue("purple");
        assertTrue(preferenceCollectionsMatch(existingPreferences, VALID_REGION_WIDGET.getPreferences()));
        assertTrue(preferencesHaveValidRegionWidgetId(VALID_REGION_WIDGET.getPreferences()));
    }
View Full Code Here

    }
       
    @Test
    public void saveRegionWidgetCollapsedState() {
        final boolean COLLAPSED = true;
        RegionWidget regionWidget = new RegionWidget(VALID_REGION_WIDGET_ID);
       
        expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(regionWidget);               
        regionWidget.setCollapsed(COLLAPSED);
        expect(regionWidgetRepository.save(regionWidget)).andReturn(regionWidget);
        replay(regionWidgetRepository);

        assertThat(regionWidgetService.saveRegionWidgetCollapsedState(VALID_REGION_WIDGET_ID, COLLAPSED).isCollapsed(), is(COLLAPSED));
    }
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.