List of usage examples for com.liferay.portal.kernel.test.util RandomTestUtil randomLocaleStringMap
public static Map<Locale, String> randomLocaleStringMap()
From source file:com.liferay.asset.service.test.AssetTagFinderTest.java
License:Open Source License
@Before public void setUp() throws Exception { _group = GroupTestUtil.addGroup();/*from www.ja va 2 s. c o m*/ Layout layout = LayoutTestUtil.addLayout(_group); Map<Locale, String> nameMap = new HashMap<>(); String name = RandomTestUtil.randomString(); nameMap.put(LocaleUtil.getDefault(), name); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); _scopeGroup = GroupLocalServiceUtil.addGroup(TestPropsValues.getUserId(), _group.getParentGroupId(), Layout.class.getName(), layout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, RandomTestUtil.randomLocaleStringMap(), GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name), false, true, serviceContext); }
From source file:com.liferay.calendar.ratings.test.CalendarBookingRatingsTest.java
License:Open Source License
@Override protected BaseModel<?> addBaseModel(BaseModel<?> parentBaseModel, ServiceContext serviceContext) throws Exception { Calendar calendar = (Calendar) parentBaseModel; long startTime = System.currentTimeMillis(); return CalendarBookingLocalServiceUtil.addCalendarBooking(TestPropsValues.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, CalendarBookingConstants.RECURRING_CALENDAR_BOOKING_ID_DEFAULT, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext);// ww w. j a v a 2 s . c o m }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerTest.java
License:Open Source License
protected void addCalendarBooking(LocalizedValuesMap titleMap) { try {/* www . ja v a 2s . c o m*/ ServiceContext serviceContext = new ServiceContext(); CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(), serviceContext); Calendar calendar = CalendarLocalServiceUtil.addCalendar(_user.getUserId(), _group.getGroupId(), calendarResource.getCalendarResourceId(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), StringPool.UTC, RandomTestUtil.randomInt(0, 255), false, false, false, serviceContext); long startTime = DateUtil.newTime() + RandomTestUtil.randomInt(); long endTime = startTime + Time.HOUR; HashMap<Locale, String> hashMap = new HashMap<>(); CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, 0, titleMap.getValues(), hashMap, null, startTime, endTime, false, null, 0, "email", 0, "email", serviceContext); } catch (PortalException pe) { throw new RuntimeException(pe); } }
From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testAddCalendarBookingWorkflowActionPublish() throws PortalException { ServiceContext serviceContext = createServiceContext(); CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(), serviceContext);//from ww w . j a va 2s .co m Calendar calendar = calendarResource.getDefaultCalendar(); long startTime = DateUtil.newTime(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext); Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, calendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testAddCalendarBookingWorkflowActionSaveDraft() throws PortalException { ServiceContext serviceContext = createServiceContext(); CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(), serviceContext);//from w ww. j a v a2 s . com Calendar calendar = calendarResource.getDefaultCalendar(); long startTime = DateUtil.newTime(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext); Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testUpdateCalendarBookingWorkflowActionPublish() throws PortalException { ServiceContext serviceContext = createServiceContext(); CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(), serviceContext);/*from www . j a va 2 s. c o m*/ Calendar calendar = calendarResource.getDefaultCalendar(); long startTime = DateUtil.newTime(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0], RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, RandomTestUtil.randomInt(), serviceContext); Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, calendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testUpdateCalendarBookingWorkflowActionSaveDraft() throws PortalException { ServiceContext serviceContext = createServiceContext(); CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(), serviceContext);/* www . ja v a 2 s.c o m*/ Calendar calendar = calendarResource.getDefaultCalendar(); long startTime = DateUtil.newTime(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0], RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, RandomTestUtil.randomInt(), serviceContext); Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testAddCalendarBookingDoesNotNotifyCreatorTwice() throws Exception { ServiceContext serviceContext = createServiceContext(); _invitingUser = UserTestUtil.addUser(); Calendar calendar = CalendarTestUtil.addCalendar(_invitingUser, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(_user, serviceContext); long startTime = System.currentTimeMillis() + Time.MINUTE; long endTime = startTime + Time.HOUR; long firstReminder = Time.MINUTE; serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingTestUtil.addCalendarBooking(_invitingUser, calendar, new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), startTime, endTime, null, (int) firstReminder, NotificationType.EMAIL, 0, NotificationType.EMAIL, serviceContext); CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking, CalendarBookingWorkflowConstants.STATUS_APPROVED, serviceContext); CalendarBookingLocalServiceUtil.checkCalendarBookings(); String mailMessageSubject = "Calendar: Event Reminder for " + StringPool.QUOTE + calendarBooking.getTitle(LocaleUtil.getDefault()) + StringPool.QUOTE; List<com.dumbster.smtp.MailMessage> mailMessages = MailServiceTestUtil.getMailMessages("Subject", mailMessageSubject);//from www . j a va2s . co m Assert.assertEquals(mailMessages.toString(), 2, mailMessages.size()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCalendarBooking() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); long startTime = System.currentTimeMillis(); Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence(); CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar, startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext); long instanceStartTime = startTime + Time.DAY * 2; Map<Locale, String> titleMap = RandomTestUtil.randomLocaleStringMap(); CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance( _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), titleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); CalendarBookingLocalServiceUtil.deleteCalendarBooking(calendarBooking); calendarBookingInstance = CalendarBookingLocalServiceUtil .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId()); Assert.assertEquals(titleMap, calendarBookingInstance.getTitleMap()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCalendarBookingWithAllFollowingInstances() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); long startTime = System.currentTimeMillis(); Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence(); CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar, startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext); long instanceStartTime = startTime + Time.DAY * 2; Map<Locale, String> titleMap = RandomTestUtil.randomLocaleStringMap(); CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance( _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), titleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); CalendarBookingLocalServiceUtil.deleteCalendarBookingInstance(calendarBooking, 1, true, true); calendarBookingInstance = CalendarBookingLocalServiceUtil .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId()); Assert.assertNull(calendarBookingInstance); assertCalendarBookingInstancesCount(calendarBooking.getCalendarBookingId(), 1); }