Example usage for com.liferay.portal.kernel.util LocaleUtil ITALY

List of usage examples for com.liferay.portal.kernel.util LocaleUtil ITALY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util LocaleUtil ITALY.

Prototype

Locale ITALY

To view the source code for com.liferay.portal.kernel.util LocaleUtil ITALY.

Click Source Link

Usage

From source file:com.liferay.journal.service.test.JournalArticleLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateDDMStructurePredefinedValues() throws Exception {
    Set<Locale> availableLocales = DDMFormTestUtil.createAvailableLocales(LocaleUtil.BRAZIL, LocaleUtil.FRENCH,
            LocaleUtil.ITALY, LocaleUtil.US);

    DDMForm ddmForm = DDMFormTestUtil.createDDMForm(availableLocales, LocaleUtil.US);

    DDMFormField ddmFormField = DDMFormTestUtil.createLocalizableTextDDMFormField("name");

    LocalizedValue label = new LocalizedValue(LocaleUtil.US);

    label.addString(LocaleUtil.BRAZIL, "rtulo");
    label.addString(LocaleUtil.FRENCH, "tiquette");
    label.addString(LocaleUtil.ITALY, "etichetta");
    label.addString(LocaleUtil.US, "label");

    ddmFormField.setLabel(label);/*from   ww w.  j a v  a2 s  .  co  m*/

    ddmForm.addDDMFormField(ddmFormField);

    DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(_group.getGroupId(),
            JournalArticle.class.getName(), ddmForm);

    DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(_group.getGroupId(),
            ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class),
            TemplateConstants.LANG_TYPE_VM, JournalTestUtil.getSampleTemplateXSL(), LocaleUtil.US);

    Map<Locale, String> values = new HashMap<>();

    values.put(LocaleUtil.BRAZIL, "Valor Predefinido");
    values.put(LocaleUtil.FRENCH, "Valeur Prdfinie");
    values.put(LocaleUtil.ITALY, "Valore Predefinito");
    values.put(LocaleUtil.US, "Predefined Value");

    String content = DDMStructureTestUtil.getSampleStructuredContent(values, LocaleUtil.US.toString());

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    Map<Locale, String> titleMap = new HashMap<>();

    titleMap.put(LocaleUtil.US, "Test Article");

    JournalArticle journalArticle = JournalArticleLocalServiceUtil.addArticle(serviceContext.getUserId(),
            serviceContext.getScopeGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            ClassNameLocalServiceUtil.getClassNameId(DDMStructure.class), ddmStructure.getStructureId(),
            StringPool.BLANK, true, 0, titleMap, null, content, ddmStructure.getStructureKey(),
            ddmTemplate.getTemplateKey(), null, 1, 1, 1965, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0, true,
            true, false, null, null, null, null, serviceContext);

    DDMStructure actualDDMStrucure = journalArticle.getDDMStructure();

    Assert.assertEquals(actualDDMStrucure.getStructureId(), ddmStructure.getStructureId());

    DDMFormField actualDDMFormField = actualDDMStrucure.getDDMFormField("name");

    Assert.assertNotNull(actualDDMFormField);

    LocalizedValue actualDDMFormFieldPredefinedValue = actualDDMFormField.getPredefinedValue();

    Assert.assertEquals("Valor Predefinido", actualDDMFormFieldPredefinedValue.getString(LocaleUtil.BRAZIL));
    Assert.assertEquals("Valeur Prdfinie", actualDDMFormFieldPredefinedValue.getString(LocaleUtil.FRENCH));
    Assert.assertEquals("Valore Predefinito", actualDDMFormFieldPredefinedValue.getString(LocaleUtil.ITALY));
    Assert.assertEquals("Predefined Value", actualDDMFormFieldPredefinedValue.getString(LocaleUtil.US));
}