Example usage for com.liferay.portal.kernel.test.util RandomTestUtil randomLocaleStringMap

List of usage examples for com.liferay.portal.kernel.test.util RandomTestUtil randomLocaleStringMap

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.test.util RandomTestUtil randomLocaleStringMap.

Prototype

public static Map<Locale, String> randomLocaleStringMap(Locale locale) 

Source Link

Usage

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

License:Open Source License

@Test
public void testSearch() throws Exception {
    ServiceContext serviceContext = new ServiceContext();

    CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
            serviceContext);//from   w  ww . ja  v  a  2s  . c  o  m

    Locale locale = LocaleUtil.getDefault();

    Map<Locale, String> nameMap = RandomTestUtil.randomLocaleStringMap(locale);

    Calendar expectedCalendar = CalendarLocalServiceUtil.addCalendar(_user.getUserId(), _group.getGroupId(),
            calendarResource.getCalendarResourceId(), nameMap, RandomTestUtil.randomLocaleStringMap(),
            StringPool.UTC, RandomTestUtil.randomInt(0, 255), false, false, false, serviceContext);

    CalendarLocalServiceUtil.addCalendar(_user.getUserId(), _group.getGroupId(),
            calendarResource.getCalendarResourceId(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomLocaleStringMap(), StringPool.UTC, RandomTestUtil.randomInt(0, 255), false,
            false, false, serviceContext);

    List<Calendar> actualCalendars = CalendarLocalServiceUtil.search(_group.getCompanyId(),
            new long[] { _group.getGroupId() }, new long[] { calendarResource.getCalendarResourceId() },
            nameMap.get(locale), true, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new CalendarNameComparator());

    Assert.assertEquals(actualCalendars.toString(), 1, actualCalendars.size());

    Calendar actualCalendar = actualCalendars.get(0);

    Assert.assertEquals(expectedCalendar.getCalendarId(), actualCalendar.getCalendarId());
    Assert.assertEquals(expectedCalendar.getNameMap(), actualCalendar.getNameMap());
}