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

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

Introduction

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

Prototype

Locale BRAZIL

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

Click Source Link

Usage

From source file:com.liferay.calendar.search.test.CalendarIndexerIndexedFieldsTest.java

License:Open Source License

@Test
public void testIndexedFieldsMissingDescription() throws Exception {
    String originalName = "entity title";
    String translatedName = "ttulo da entidade";

    Calendar calendar = addCalendar(new LocalizedValuesMap() {
        {/*w w  w  . j a va  2 s  .  c o m*/
            put(LocaleUtil.US, originalName);
            put(LocaleUtil.BRAZIL, translatedName);
        }
    }, new LocalizedValuesMap());

    Map<String, String> map = new HashMap<>();

    populateExpectedFieldValues(calendar, map);

    map.put(Field.NAME, originalName);
    map.put(Field.NAME + "_en_US", originalName);
    map.put(Field.NAME + "_pt_BR", translatedName);

    String keywords = translatedName;

    Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.BRAZIL);

    FieldValuesAssert.assertFieldValues(map, document, keywords);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateCalendarBookingPreservesDescriptionTranslations() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

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

    oldDescriptionMap.put(LocaleUtil.BRAZIL, RandomTestUtil.randomString());
    oldDescriptionMap.put(LocaleUtil.GERMANY, RandomTestUtil.randomString());
    oldDescriptionMap.put(LocaleUtil.SPAIN, RandomTestUtil.randomString());
    oldDescriptionMap.put(LocaleUtil.US, RandomTestUtil.randomString());

    long startTime = System.currentTimeMillis();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBookingWithTitleAndDescription(
            _user, calendar, RandomTestUtil.randomLocaleStringMap(), oldDescriptionMap, startTime,
            startTime + (Time.HOUR * 10), serviceContext);

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

    newDescriptionMap.put(LocaleUtil.GERMANY, "");
    newDescriptionMap.put(LocaleUtil.SPAIN, RandomTestUtil.randomString());
    newDescriptionMap.put(LocaleUtil.US, oldDescriptionMap.get(LocaleUtil.US));

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0],
            RandomTestUtil.randomLocaleStringMap(), newDescriptionMap, RandomTestUtil.randomString(), startTime,
            startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext);

    calendarBooking = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBooking.getCalendarBookingId());

    Assert.assertEquals(oldDescriptionMap.get(LocaleUtil.BRAZIL),
            calendarBooking.getDescription(LocaleUtil.BRAZIL));
    Assert.assertEquals(newDescriptionMap.get(LocaleUtil.SPAIN),
            calendarBooking.getDescription(LocaleUtil.SPAIN));
    Assert.assertEquals(newDescriptionMap.get(LocaleUtil.US), calendarBooking.getDescription(LocaleUtil.US));

    Map<Locale, String> descriptionMap = calendarBooking.getDescriptionMap();

    Assert.assertFalse(descriptionMap.containsKey(LocaleUtil.GERMANY));
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateCalendarBookingPreservesTitleTranslations() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

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

    oldTitleMap.put(LocaleUtil.BRAZIL, RandomTestUtil.randomString());
    oldTitleMap.put(LocaleUtil.GERMANY, RandomTestUtil.randomString());
    oldTitleMap.put(LocaleUtil.SPAIN, RandomTestUtil.randomString());
    oldTitleMap.put(LocaleUtil.US, RandomTestUtil.randomString());

    long startTime = System.currentTimeMillis();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBookingWithTitleAndDescription(
            _user, calendar, oldTitleMap, RandomTestUtil.randomLocaleStringMap(), startTime,
            startTime + (Time.HOUR * 10), serviceContext);

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

    newTitleMap.put(LocaleUtil.GERMANY, "");
    newTitleMap.put(LocaleUtil.SPAIN, RandomTestUtil.randomString());
    newTitleMap.put(LocaleUtil.US, oldTitleMap.get(LocaleUtil.US));

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0], newTitleMap,
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime,
            startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext);

    calendarBooking = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBooking.getCalendarBookingId());

    Assert.assertEquals(oldTitleMap.get(LocaleUtil.BRAZIL), calendarBooking.getTitle(LocaleUtil.BRAZIL));
    Assert.assertEquals(newTitleMap.get(LocaleUtil.SPAIN), calendarBooking.getTitle(LocaleUtil.SPAIN));
    Assert.assertEquals(oldTitleMap.get(LocaleUtil.US), calendarBooking.getTitle(LocaleUtil.US));

    Map<Locale, String> titleMap = calendarBooking.getTitleMap();

    Assert.assertFalse(titleMap.containsKey(LocaleUtil.GERMANY));
}

From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormDisplayContextTest.java

License:Open Source License

@Test
public void testDDMFormRenderingContextLocaleIsSiteLocale() {
    DDMForm ddmForm = createDDMForm(LocaleUtil.BRAZIL);

    DDMFormRenderingContext ddmFormRenderingContext = _ddlFormDisplayContext
            .createDDMFormRenderingContext(ddmForm);

    Assert.assertEquals(LocaleUtil.BRAZIL, ddmFormRenderingContext.getLocale());
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected Field createBRField(long ddmStructureId, String fieldName, List<Serializable> ptValues) {

    return new MockField(ddmStructureId, fieldName, ptValues, LocaleUtil.BRAZIL);
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected Value createLocalizedValue(String enValue, String ptValue, Locale defaultLocale) {

    Value value = new LocalizedValue(defaultLocale);

    value.addString(LocaleUtil.BRAZIL, ptValue);
    value.addString(LocaleUtil.US, enValue);

    return value;
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected Map<Locale, List<Serializable>> createValuesMap(List<Serializable> enValues,
        List<Serializable> ptValues) {

    Map<Locale, List<Serializable>> valuesMap = new HashMap<>();

    if (enValues != null) {
        valuesMap.put(LocaleUtil.US, enValues);
    }/*  www.jav  a2  s  .  c o m*/

    if (ptValues != null) {
        valuesMap.put(LocaleUtil.BRAZIL, ptValues);
    }

    return valuesMap;
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected void setUpLanguageUtil() {
    Set<Locale> availableLocales = SetUtil
            .fromArray(new Locale[] { LocaleUtil.BRAZIL, LocaleUtil.SPAIN, LocaleUtil.US });

    whenLanguageGetAvailableLocalesThen(availableLocales);

    whenLanguageGet(LocaleUtil.BRAZIL, "no", "No");
    whenLanguageGet(LocaleUtil.BRAZIL, "yes", "Sim");
    whenLanguageGet(LocaleUtil.SPAIN, "latitude", "Latitud");
    whenLanguageGet(LocaleUtil.SPAIN, "longitude", "Longitud");
    whenLanguageGet(LocaleUtil.US, "latitude", "Latitude");
    whenLanguageGet(LocaleUtil.US, "longitude", "Longitude");
    whenLanguageGet(LocaleUtil.US, "no", "No");
    whenLanguageGet(LocaleUtil.US, "yes", "Yes");

    whenLanguageGetLanguageId(LocaleUtil.BRAZIL, "pt_BR");
    whenLanguageGetLanguageId(LocaleUtil.SPAIN, "es_ES");
    whenLanguageGetLanguageId(LocaleUtil.US, "en_US");

    whenLanguageIsAvailableLocale("en_US");
    whenLanguageIsAvailableLocale("es_ES");
    whenLanguageIsAvailableLocale("pt_BR");

    whenLanguageIsAvailableLocale(LocaleUtil.BRAZIL);
    whenLanguageIsAvailableLocale(LocaleUtil.SPAIN);
    whenLanguageIsAvailableLocale(LocaleUtil.US);

    LanguageUtil languageUtil = new LanguageUtil();

    languageUtil.setLanguage(language);//from   w  w  w  .ja va  2s . c o m
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected void setUpLocaleUtil() {
    mockStatic(LocaleUtil.class);

    when(LocaleUtil.fromLanguageId("en_US")).thenReturn(LocaleUtil.US);

    when(LocaleUtil.fromLanguageId("pt_BR")).thenReturn(LocaleUtil.BRAZIL);

    when(LocaleUtil.getDefault()).thenReturn(LocaleUtil.US);

    when(LocaleUtil.toLanguageId(LocaleUtil.US)).thenReturn("en_US");

    when(LocaleUtil.toLanguageId(LocaleUtil.BRAZIL)).thenReturn("pt_BR");

    when(LocaleUtil.toLanguageIds((Locale[]) Matchers.any())).then(new Answer<String[]>() {

        @Override/*from  www.  jav a 2s . com*/
        public String[] answer(InvocationOnMock invocationOnMock) throws Throwable {

            Object[] args = invocationOnMock.getArguments();

            Locale[] locales = (Locale[]) args[0];

            String[] languageIds = new String[locales.length];

            for (int i = 0; i < locales.length; i++) {
                languageIds[i] = LocaleUtil.toLanguageId(locales[i]);
            }

            return languageIds;
        }

    });
}

From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java

License:Open Source License

protected void setUpResourceBundleUtil() {
    mockStatic(ResourceBundleUtil.class);

    when(ResourceBundleUtil.getBundle("content.Language", LocaleUtil.BRAZIL, _classLoader))
            .thenReturn(_resourceBundle);

    when(ResourceBundleUtil.getBundle("content.Language", LocaleUtil.US, _classLoader))
            .thenReturn(_resourceBundle);
}