DDMFormContextToDDMFormValues implements DDMFormContextDeserializer<DDMFormValues> { @Override public DDMFormValues deserialize( DDMFormContextDeserializerRequest ddmFormContextDeserializerRequest) throws PortalException { String serializedFormContext = ddmFormContextDeserializerRequest.getProperty( "serializedFormContext"); if (Validator.isNull(serializedFormContext)) { throw new IllegalStateException( "The property \"serializedFormContext\" is required"); } DDMForm ddmForm = ddmFormContextDeserializerRequest.getProperty( "ddmForm"); if (Validator.isNull(serializedFormContext)) { throw new IllegalStateException( "The property \"ddmForm\" is required"); } Locale currentLocale = ddmFormContextDeserializerRequest.getProperty( "currentLocale"); if (currentLocale == null) { currentLocale = LocaleThreadLocal.getSiteDefaultLocale(); } return deserialize(ddmForm, serializedFormContext, currentLocale); }  @Override DDMFormValues deserialize(
			DDMFormContextDeserializerRequest ddmFormContextDeserializerRequest);  }
@Test public void testDeserializeWithLanguageDifferentThanSiteDefault() throws Exception { String serializedDDMFormValues = read("ddm-form-values.json"); DDMForm ddmForm = DDMFormTestUtil.createDDMForm(); ddmForm.addDDMFormField( DDMFormTestUtil.createTextDDMFormField( "TextField1", true, false, false)); ddmForm.addDDMFormField( DDMFormTestUtil.createTextDDMFormField( "TextField2", true, false, false)); DDMFormContextDeserializerRequest ddmFormContextDeserializerRequest = DDMFormContextDeserializerRequest.with( ddmForm, serializedDDMFormValues); ddmFormContextDeserializerRequest.addProperty( "currentLocale", LocaleUtil.BRAZIL); DDMFormValues ddmFormValues = _ddmFormContextToDDMFormValues.deserialize( ddmFormContextDeserializerRequest); Assert.assertNotEquals(LocaleUtil.getSiteDefault(), LocaleUtil.BRAZIL); Assert.assertEquals( ddmFormValues.getDefaultLocale(), LocaleUtil.BRAZIL); Set<Locale> availableLocales = ddmFormValues.getAvailableLocales(); Assert.assertEquals( availableLocales.toString(), 1, availableLocales.size()); Assert.assertTrue(availableLocales.contains(LocaleUtil.BRAZIL)); }