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, Document document, String message) 

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() {
        {//from  w ww  . java2s .co m
            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.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() {
        {//w  w  w  . j av a 2s  .  co 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 v a2s .  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);
}