Example usage for com.liferay.portal.search.test.util FieldValuesAssert assertFieldValues

List of usage examples for com.liferay.portal.search.test.util FieldValuesAssert assertFieldValues

Introduction

In this page you can find the example usage for com.liferay.portal.search.test.util FieldValuesAssert assertFieldValues.

Prototype

public static void assertFieldValues(Map<String, String> expected, String prefix, Document document,
            String message) 

Source Link

Usage

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

License:Open Source License

protected void assertFieldValues(String prefix, Locale locale, Map<String, String> titleStrings,
        String searchTerm) {//from   w  ww .j  av a2  s.com

    Document document = calendarSearchFixture.searchOnlyOne(searchTerm, locale);

    FieldValuesAssert.assertFieldValues(titleStrings, prefix, document, searchTerm);
}

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

License:Open Source License

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

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

    addCalendar(new LocalizedValuesMap() {
        {/*  w w  w.  j  a va 2 s  . c  o m*/
            put(LocaleUtil.US, originalName);
            put(LocaleUtil.JAPAN, japaneseName);
        }
    }, new LocalizedValuesMap() {
        {
            put(LocaleUtil.US, description);
            put(LocaleUtil.JAPAN, description);
        }
    });

    Map<String, String> nameMap = new HashMap<String, String>() {
        {
            put("name", originalName);
            put("name_en_US", originalName);
            put("name_ja_JP", japaneseName);
        }
    };

    Map<String, String> descriptionMap = new HashMap<String, String>() {
        {
            put("description", description);
            put("description_en_US", description);
            put("description_ja_JP", description);
        }
    };

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

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

    stream.forEach(keywords -> {
        Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.JAPAN);

        FieldValuesAssert.assertFieldValues(nameMap, "name", document, keywords);

        FieldValuesAssert.assertFieldValues(descriptionMap, "description", document, keywords);
    });
}

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

License:Open Source License

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

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

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

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

    namesStream.forEach(name -> {//from   w w w.  j  av a 2  s.c om
        addCalendar(new LocalizedValuesMap() {
            {
                put(LocaleUtil.US, originalName);
                put(LocaleUtil.JAPAN, name);
            }
        }, new LocalizedValuesMap() {
            {
                put(LocaleUtil.US, description);
                put(LocaleUtil.JAPAN, description);
            }
        });
    });

    Map<String, String> nameMap = new HashMap<String, String>() {
        {
            put("name", originalName);
            put("name_en_US", originalName);
            put("name_ja_JP", full);
        }
    };

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

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

    keywordsStream.forEach(keywords -> {
        Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.JAPAN);

        FieldValuesAssert.assertFieldValues(nameMap, "name", document, keywords);
    });
}

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMIndexerImplTest.java

License:Open Source License

@Test
public void testFormWithOneAvailableLocaleSameAsDefaultLocale() {
    Locale defaultLocale = LocaleUtil.JAPAN;
    Locale translationLocale = LocaleUtil.JAPAN;

    Set<Locale> availableLocales = Collections.singleton(defaultLocale);

    DDMForm ddmForm = DDMFormTestUtil.createDDMForm(availableLocales, defaultLocale);

    String fieldName = "text1";
    String indexType = "text";

    ddmForm.addDDMFormField(createDDMFormField(fieldName, indexType));

    String fieldValue = "??";

    DDMFormFieldValue ddmFormFieldValue = createDDMFormFieldValue(fieldName, translationLocale, fieldValue,
            defaultLocale);//from www  . j  a v  a 2  s  .  co  m

    Document document = createDocument();

    DDMStructure ddmStructure = createDDMStructure(ddmForm);

    DDMFormValues ddmFormValues = createDDMFormValues(ddmForm, ddmFormFieldValue);

    ddmIndexer.addAttributes(document, ddmStructure, ddmFormValues);

    Map<String, String> map = _withSortableValues(
            Collections.singletonMap("ddm__text__NNNNN__text1_ja_JP", fieldValue));

    FieldValuesAssert.assertFieldValues(
            _replaceKeys("NNNNN", String.valueOf(ddmStructure.getStructureId()), map), "ddm__text", document,
            fieldValue);
}

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMIndexerImplTest.java

License:Open Source License

@Test
public void testFormWithTwoAvailableLocalesAndFieldWithNonDefaultLocale() {
    Locale defaultLocale = LocaleUtil.US;
    Locale translationLocale = LocaleUtil.JAPAN;

    Set<Locale> availableLocales = new HashSet<>(Arrays.asList(defaultLocale, translationLocale));

    DDMForm ddmForm = DDMFormTestUtil.createDDMForm(availableLocales, defaultLocale);

    String fieldName = "text1";
    String indexType = "text";

    ddmForm.addDDMFormField(createDDMFormField(fieldName, indexType));

    String fieldValue = "??";

    DDMFormFieldValue ddmFormFieldValue = createDDMFormFieldValue(fieldName, translationLocale, fieldValue,
            defaultLocale);//  ww  w.  j a  v a  2 s  . c o  m

    Document document = createDocument();

    DDMStructure ddmStructure = createDDMStructure(ddmForm);

    DDMFormValues ddmFormValues = createDDMFormValues(ddmForm, ddmFormFieldValue);

    ddmIndexer.addAttributes(document, ddmStructure, ddmFormValues);

    Map<String, String> map = _withSortableValues(
            Collections.singletonMap("ddm__text__NNNNN__text1_ja_JP", fieldValue));

    FieldValuesAssert.assertFieldValues(
            _replaceKeys("NNNNN", String.valueOf(ddmStructure.getStructureId()), map), "ddm__text", document,
            fieldValue);
}

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMIndexerImplTest.java

License:Open Source License

@Test
public void testFormWithTwoAvailableLocalesAndFieldWithTwoLocales() {
    Locale defaultLocale = LocaleUtil.JAPAN;
    Locale translationLocale = LocaleUtil.US;

    Set<Locale> availableLocales = new HashSet<>(Arrays.asList(defaultLocale, translationLocale));

    DDMForm ddmForm = DDMFormTestUtil.createDDMForm(availableLocales, defaultLocale);

    String fieldName = "text1";
    String indexType = "text";

    DDMFormField ddmFormField = createDDMFormField(fieldName, indexType);

    ddmForm.addDDMFormField(ddmFormField);

    String fieldValueJP = "??";
    String fieldValueUS = "Create New";

    DDMFormFieldValue ddmFormFieldValueJP = createDDMFormFieldValue(fieldName, defaultLocale, fieldValueJP,
            defaultLocale);/*from w  w  w  .  ja  va2 s.  c o  m*/

    DDMFormFieldValue ddmFormFieldValueUS = createDDMFormFieldValue(fieldName, translationLocale, fieldValueUS,
            defaultLocale);

    Document document = createDocument();

    DDMStructure ddmStructure = createDDMStructure(ddmForm);

    DDMFormValues ddmFormValues = createDDMFormValues(ddmForm, ddmFormFieldValueJP, ddmFormFieldValueUS);

    ddmIndexer.addAttributes(document, ddmStructure, ddmFormValues);

    Map<String, String> map = _withSortableValues(new HashMap<String, String>() {
        {
            put("ddm__text__NNNNN__text1_ja_JP", fieldValueJP);
            put("ddm__text__NNNNN__text1_en_US", fieldValueUS);
        }
    });

    FieldValuesAssert.assertFieldValues(
            _replaceKeys("NNNNN", String.valueOf(ddmStructure.getStructureId()), map), "ddm__text", document,
            fieldValueJP);
}