Package org.apache.rave.portal.model

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


        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


        assertThat(converter.convert(template), is(sameInstance(template)));
    }

    @Test
    public void nullConversion() {
        RegionWidgetPreference template = null;
        assertThat(converter.convert(template), is(nullValue()));
    }
View Full Code Here

    }


    @Test
    public void convertValid() {
        RegionWidgetPreference template = new RegionWidgetPreferenceImpl();
        template.setName("TEST_A");
        template.setRegionWidgetId(42L);
        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

public class ModelUtilsTest {
    long VALID_REGION_WIDGET_ID = 1L;

    @Test
    public void normalizeRegionWidgetPreference() {
        RegionWidgetPreference testPreference = new RegionWidgetPreferenceImpl( null, "camelCaseName", "FOO");
        ModelUtils.normalizeRegionWidgetPreference(VALID_REGION_WIDGET_ID, testPreference);

        assertTrue(testPreference.getRegionWidgetId() == VALID_REGION_WIDGET_ID);
    }
View Full Code Here

        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 RegionWidgetPreferenceImpl(null, "age", "30");
        RegionWidgetPreference savedNewPreference = regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, newPreference);
        RegionWidgetPreference updatedPreference = new RegionWidgetPreferenceImpl(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");
View Full Code Here

        }

        //We know the lists are the same length - so as long as all the savedPreferences exist and match the updated
        //preferences then we are all good.
        for (RegionWidgetPreference savedPreference : savedPreferences) {
            RegionWidgetPreference updatedPreference = updatedPreferencesMap.get(savedPreference.getName());
            if (updatedPreference == null || !StringUtils.equals(savedPreference.getName(), updatedPreference.getName())
                    || !StringUtils.equals(savedPreference.getValue(), updatedPreference.getValue())) {
                return false;
            }
        }

        return true;
View Full Code Here

        RegionWidget rw = new RegionWidget();
        rw.setEntityId(1L);
        rw.setCollapsed(VALID_COLLAPSED);
        rw.setWidget(w);
        rw.setRegion(region);
        rw.setPreferences(Arrays.asList(new RegionWidgetPreference(1L, 1L, "color", "blue"),
                                        new RegionWidgetPreference(2L, 1L, "speed", "fast"),
                                        new RegionWidgetPreference(3L, 1L, null, null)));

        final String markup =
            "<script>rave.registerWidget(1, {type: 'OpenSocial'," +
            " regionWidgetId: 1," +
            " widgetUrl: '" + VALID_GADGET_URL +"', " +
View Full Code Here

public class ModelUtilsTest {
    String VALID_REGION_WIDGET_ID = "1";

    @Test
    public void normalizeRegionWidgetPreference() {
        RegionWidgetPreference testPreference = new RegionWidgetPreferenceImpl( null, "camelCaseName", "FOO");
        ModelUtils.normalizeRegionWidgetPreference(VALID_REGION_WIDGET_ID, testPreference);

        assertTrue(testPreference.getRegionWidgetId() == VALID_REGION_WIDGET_ID);
    }
View Full Code Here

        RegionWidgetImpl rw = new RegionWidgetImpl();
        RegionWidgetImpl rwResults;

        rw.setPreferences(Lists.<RegionWidgetPreference>newLinkedList());
        RegionWidgetPreference preference = new RegionWidgetPreferenceImpl();
        preference.setName("name");
        preference.setValue("value");
        rw.setWidgetId("1234L");
        rw.getPreferences().add(preference);
        rw.setLocked(false);
        rw.setCollapsed(false);
        rw.setHideChrome(false);
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();
View Full Code Here

TOP

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

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.