Example usage for com.liferay.portal.kernel.settings LocalizedValuesMap LocalizedValuesMap

List of usage examples for com.liferay.portal.kernel.settings LocalizedValuesMap LocalizedValuesMap

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.settings LocalizedValuesMap LocalizedValuesMap.

Prototype

public LocalizedValuesMap() 

Source Link

Usage

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

License:Open Source License

@Test
public void testIndexedFields() throws Exception {
    String originalTitle = "entity title";
    String translatedTitle = "entitas neve";

    String description = StringUtil.toLowerCase(RandomTestUtil.randomString());

    CalendarBooking calendarBooking = addCalendarBooking(new LocalizedValuesMap() {
        {// w  w  w .j a v  a  2 s . c om
            put(LocaleUtil.US, originalTitle);
            put(LocaleUtil.HUNGARY, translatedTitle);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, originalTitle);
            put(LocaleUtil.HUNGARY, translatedTitle);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, description);
            put(LocaleUtil.HUNGARY, description);
        }
    });

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

    map.put(Field.CLASS_NAME_ID, String.valueOf(portal.getClassNameId(Calendar.class)));

    map.put(Field.EXPIRATION_DATE, "99950812133000");
    map.put(Field.EXPIRATION_DATE.concat("_sortable"), "9223372036854775807");
    map.put(Field.PRIORITY, "0.0");
    map.put(Field.PUBLISH_DATE, "19700101000000");
    map.put(Field.PUBLISH_DATE.concat("_sortable"), "0");
    map.put(Field.RELATED_ENTRY, "true");
    map.put(Field.STAGING_GROUP, "false");
    map.put(Field.STATUS, "0");
    map.put("viewActionId", CalendarActionKeys.VIEW_BOOKING_DETAILS);

    populateTitle(originalTitle, map);

    populateTranslatedTitle(translatedTitle, map);

    CalendarResource calendarResource = calendarBooking.getCalendarResource();

    populateCalendarResource(calendarResource, map);

    Calendar calendar = calendarResource.getDefaultCalendar();

    populateCalendar(calendar, map);

    populateCalendarBooking(calendarBooking, map);

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmm");

    populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), dateFormat, map);
    populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), dateFormat, map);

    calendarFieldsFixture.populateGroupRoleId(map);
    calendarFieldsFixture.populateRoleId("Owner", map);
    calendarFieldsFixture.populateUID(calendarBooking, map);

    String keywords = "nev";

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

    adjustDatePrecision(Field.CREATE_DATE, document, dateFormat);
    adjustDatePrecision(Field.MODIFIED_DATE, document, dateFormat);

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

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

License:Open Source License

@Test
public void testJapaneseTitle() throws Exception {
    String originalName = "entity name";
    String japaneseName = "??";

    String description = StringUtil.toLowerCase(RandomTestUtil.randomString());

    addCalendarBooking(new LocalizedValuesMap() {
        {/*ww w. ja  v  a2s . c o  m*/
            put(LocaleUtil.US, originalName);
            put(LocaleUtil.JAPAN, japaneseName);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, originalName);
            put(LocaleUtil.JAPAN, japaneseName);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, description);
            put(LocaleUtil.JAPAN, description);
        }
    });

    Map<String, String> titleMap = new HashMap<String, String>() {
        {
            put("title_en_US", originalName);
            put("title_ja_JP", japaneseName);
        }
    };

    String word1 = "?";
    String word2 = "?";
    String prefix1 = "";
    String prefix2 = "";

    Stream<String> stream = Stream.of(word1, word2, prefix1, prefix2);

    stream.forEach(keywords -> assertFieldValues("title", LocaleUtil.JAPAN, titleMap, keywords));
}

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

License:Open Source License

@Test
public void testJapaneseTitleFullWordOnly() throws Exception {
    String full = "??";
    String partial1 = "";
    String partial2 = "?";

    Stream<String> titlesStream = Stream.of(full, partial1, partial2);

    String description = StringUtil.toLowerCase(RandomTestUtil.randomString());

    titlesStream.forEach(title -> {//from  w w w  . j a va  2 s  . co m
        addCalendarBooking(new LocalizedValuesMap() {
            {
                put(LocaleUtil.JAPAN, title);
            }
        }, new LocalizedValuesMap() {
            {
                put(LocaleUtil.US, description);
                put(LocaleUtil.HUNGARY, description);
            }
        }, new LocalizedValuesMap() {
            {
                put(LocaleUtil.US, description);
                put(LocaleUtil.HUNGARY, description);
            }
        });
    });

    Map<String, String> titleMap = new HashMap<String, String>() {
        {
            put("title_ja_JP", "??");
        }
    };

    String word1 = "?";
    String word2 = "?";

    Stream<String> keywordsStream = Stream.of(word1, word2);

    keywordsStream.forEach(keywords -> assertFieldValues("title", LocaleUtil.JAPAN, titleMap, keywords));
}

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

License:Open Source License

@Test
public void testIndexedFields() throws Exception {
    setUpSearchContext(_group, TestPropsValues.getUser());

    String originalTitle = "entity title";
    String translatedTitle = "entitas neve";

    addCalendarBooking(new LocalizedValuesMap() {
        {//from w ww  .  j a  v a2s  .  c om
            put(LocaleUtil.US, originalTitle);
            put(LocaleUtil.HUNGARY, translatedTitle);
        }
    });

    String searchTerm = "nev";

    assertSearchHitsLength(searchTerm, 1, LocaleUtil.HUNGARY);
}

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

License:Open Source License

@Test
public void testJapaneseTitle() throws Exception {
    setUpSearchContext(_group, TestPropsValues.getUser());

    String title = "??";

    addCalendarBooking(new LocalizedValuesMap() {
        {//w w w.  ja  va2  s .c o m
            put(LocaleUtil.JAPAN, title);
        }
    });

    String word1 = "?";
    String word2 = "?";
    String prefix1 = "";
    String prefix2 = "";

    Stream<String> searchTerms = Stream.of(word1, word2, prefix1, prefix2);

    searchTerms.forEach(searchTerm -> {
        assertSearchHitsLength(searchTerm, 1, LocaleUtil.JAPAN);
    });
}

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

License:Open Source License

@Test
public void testJapaneseTitleFullWordOnly() throws Exception {
    setUpSearchContext(_group, TestPropsValues.getUser());

    String full = "??";
    String partial1 = "";
    String partial2 = "?";

    Stream<String> titles = Stream.of(full, partial1, partial2);

    titles.forEach(title -> {//from  w  w  w.j av a2  s. c  o  m
        addCalendarBooking(new LocalizedValuesMap() {
            {
                put(LocaleUtil.JAPAN, title);
            }
        });
    });

    String word1 = "?";
    String word2 = "?";

    Stream<String> searchTerms = Stream.of(word1, word2);

    searchTerms.forEach(searchTerm -> {
        assertSearchHitsLength(searchTerm, 1, LocaleUtil.JAPAN);
    });
}

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

License:Open Source License

@Test
public void testSearch() throws Exception {
    setUpSearchContext(_group, TestPropsValues.getUser());

    String title = RandomTestUtil.randomString();

    addCalendarBooking(new LocalizedValuesMap() {
        {/*from ww  w  . j av  a  2s.com*/
            put(LocaleUtil.US, title);
        }
    });

    assertSearchHitsLength(title, 1, LocaleUtil.US);
}

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

License:Open Source License

@Test
public void testSearchNotAdmin() throws Exception {
    setUpSearchContext(_group, _user);//from   w  w w  .j a  va2 s.  c o m

    String title = RandomTestUtil.randomString();

    addCalendarBooking(new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, title);
        }
    });

    assertSearchHitsLength(title, 1, LocaleUtil.US);
}

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

License:Open Source License

@Test
public void testIndexedFields() throws Exception {
    String originalName = "entity title";
    String translatedName = "entitas neve";

    String originalDescription = "calendar description";
    String translatedDescription = "descripcin del calendario";

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

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

    populateExpectedFieldValues(calendar, map);

    map.put(Field.DESCRIPTION, originalDescription);
    map.put(Field.DESCRIPTION + "_en_US", originalDescription);
    map.put(Field.DESCRIPTION + "_hu_HU", translatedDescription);
    map.put(Field.NAME, originalName);
    map.put(Field.NAME + "_en_US", originalName);
    map.put(Field.NAME + "_hu_HU", translatedName);

    String keywords = "nev";

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

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

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 . ja va2 s.co 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);
}