Package org.apache.rave.model

Examples of org.apache.rave.model.RegionWidgetPreference


        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

        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("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

        regionWidgetApi.replaceAllRegionWidgetPreferences(INVALID_REGION_WIDGET_ID, LIST_WRAPPER);
    }

    @Test
    public void createOrReplaceRegionWidgetPreference_validParams() {
        RegionWidgetPreference PREFERENCE = new RegionWidgetPreferenceImpl(VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);

        expect(regionWidgetService.saveRegionWidgetPreference(VALID_REGION_WIDGET_ID, PREFERENCE)).andReturn(PREFERENCE);
        replay(regionWidgetService);

        RegionWidgetPreference result = regionWidgetApi.createOrReplaceRegionWidgetPreference(VALID_REGION_WIDGET_ID,
                VALID_PREFERENCE_NAME, PREFERENCE);

        verify(regionWidgetService);
        assertThat(result, sameInstance(PREFERENCE));
    }
View Full Code Here

        assertThat(result, sameInstance(PREFERENCE));
    }

    @Test(expected = IllegalArgumentException.class)
    public void createOrReplaceRegionWidgetPreference_invalidParams_preferenceName() {
        RegionWidgetPreference PREFERENCE = new RegionWidgetPreferenceImpl(VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);

        regionWidgetApi.createOrReplaceRegionWidgetPreference(VALID_REGION_WIDGET_ID, "different", PREFERENCE);
    }
View Full Code Here

        regionWidgetApi.createOrReplaceRegionWidgetPreference(VALID_REGION_WIDGET_ID, "different", PREFERENCE);
    }

    @Test(expected = IllegalArgumentException.class)
    public void createOrReplaceRegionWidgetPreference_invalidParams_regionWidgetId() {
        RegionWidgetPreference PREFERENCE = new RegionWidgetPreferenceImpl(VALID_REGION_WIDGET_ID, VALID_PREFERENCE_NAME,
                VALID_PREFERENCE_VALUE);

        expect(regionWidgetService.saveRegionWidgetPreference(INVALID_REGION_WIDGET_ID, PREFERENCE)).andThrow(
                new IllegalArgumentException());
        replay(regionWidgetService);
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

        RegionWidget regionWidget = repository.get(VALID_REGION_WIDGET_ID.toString());
        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

        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

TOP

Related Classes of org.apache.rave.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.