diff --git a/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/data/provider/test/DDMRESTDataProviderTest.java b/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/data/provider/test/DDMRESTDataProviderTest.java index e3863fd2bbbb20..24d21d789959ea 100644 --- a/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/data/provider/test/DDMRESTDataProviderTest.java +++ b/modules/apps/dynamic-data-mapping/dynamic-data-mapping-test/src/testIntegration/java/com/liferay/dynamic/data/mapping/data/provider/test/DDMRESTDataProviderTest.java @@ -24,6 +24,8 @@ import com.liferay.portal.kernel.cache.PortalCache; import com.liferay.portal.kernel.cache.PortalCacheHelperUtil; import com.liferay.portal.kernel.cache.PortalCacheManagerNames; +import com.liferay.portal.kernel.language.Language; +import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.model.ResourceConstants; import com.liferay.portal.kernel.model.Role; import com.liferay.portal.kernel.model.User; @@ -250,6 +252,27 @@ public void testGetDataWithInputParametersInURL() throws Exception { Assert.assertEquals("Brazil", keyValuePair.getValue()); } + @Test + public void testGetDataWithLocale() throws Exception { + _setUserPermissionChecker(false); + + String outputParameterId = StringUtil.randomString(); + + long ddmDataProviderId = _addDDMDataProviderInstance( + _createDDMDataProviderDDMFormValues( + false, false, StringPool.BLANK, null, outputParameterId, + "nameCurrentValue;name", "list", null, null, + _GET_COUNTRIES_URL), + false); + + _testGetDataWithLocale( + ddmDataProviderId, LocaleUtil.FRANCE, outputParameterId); + _testGetDataWithLocale( + ddmDataProviderId, LocaleUtil.GERMANY, outputParameterId); + _testGetDataWithLocale( + ddmDataProviderId, LocaleUtil.US, outputParameterId); + } + @Test public void testGetDataWithNumberOutput() throws Exception { _setUserPermissionChecker(false); @@ -610,6 +633,25 @@ private void _setUserPermissionChecker(boolean guest) throws Exception { PermissionCheckerFactoryUtil.create(user)); } + private void _testGetDataWithLocale( + long ddmDataProviderId, Locale locale, String outputParameterId) + throws Exception { + + DDMDataProviderResponse ddmDataProviderResponse = + _ddmDataProvider.getData( + _createDDMDataProviderRequest( + ddmDataProviderId, null, null, null, locale, null, null)); + + for (KeyValuePair keyValuePair : + (List)ddmDataProviderResponse.getOutput( + outputParameterId, List.class)) { + + Assert.assertEquals( + LanguageUtil.get(locale, "country." + keyValuePair.getKey()), + keyValuePair.getValue()); + } + } + private static final String _GET_COUNTRIES_URL = "http://localhost:8080/api/jsonws/country/get-countries"; @@ -628,6 +670,9 @@ private void _setUserPermissionChecker(boolean guest) throws Exception { private DDMDataProviderInstanceLocalService _ddmDataProviderInstanceLocalService; + @Inject + private Language _language; + private PermissionChecker _originalPermissionChecker; @Inject(type = RoleLocalService.class)