List of usage examples for com.liferay.portal.kernel.util Time DAY
long DAY
To view the source code for com.liferay.portal.kernel.util Time DAY.
Click Source Link
From source file:com.liferay.akismet.util.AkismetUtil.java
License:Open Source License
public static Date getReportableTime(long companyId) { int reportableTime = PrefsPortletPropsUtil.getInteger(companyId, PortletPropsKeys.AKISMET_REPORTABLE_TIME); return new Date(System.currentTimeMillis() - (reportableTime * Time.DAY)); }
From source file:com.liferay.akismet.util.AkismetUtil.java
License:Open Source License
public static Date getRetainSpamTime() { return new Date(System.currentTimeMillis() - (PortletPropsValues.AKISMET_RETAIN_SPAM_TIME * Time.DAY)); }
From source file:com.liferay.asset.test.util.BaseAssetSearchTestCase.java
License:Open Source License
protected Date[] generateRandomDates(Date startDate, int size) { Date[] dates = new Date[size]; for (int i = 0; i < size; i++) { Date date = new Date(startDate.getTime() + (RandomUtil.nextInt(365) + 1) * Time.DAY); Calendar calendar = new GregorianCalendar(); calendar.setTime(date);/* w w w. j av a 2 s . com*/ calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); dates[i] = calendar.getTime(); } return dates; }
From source file:com.liferay.calendar.internal.exportimport.data.handler.test.CalendarBookingStagedModelDataHandlerTest.java
License:Open Source License
@Test public void testImportedCalendarBookingHasRecurringParentCalendarBookingId() throws Exception { initExport();//from ww w . ja v a2 s .c o m ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup, TestPropsValues.getUserId()); Calendar calendar = CalendarTestUtil.addCalendar(stagingGroup, serviceContext); CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking( TestPropsValues.getUser(), calendar, RecurrenceTestUtil.getDailyRecurrence(), serviceContext); CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance( TestPropsValues.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), calendarBooking.getTitleMap(), calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), calendarBooking.getStartTime() + Time.DAY * 2, calendarBooking.getEndTime() + Time.DAY * 2, calendarBooking.isAllDay(), null, false, 0, null, 0, null, serviceContext); Assert.assertEquals(calendarBooking.getCalendarBookingId(), calendarBookingInstance.getRecurringCalendarBookingId()); StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, calendarBooking); initImport(); CalendarBooking exportedCalendarBooking = (CalendarBooking) readExportedStagedModel(calendarBooking); StagedModelDataHandlerUtil.importStagedModel(portletDataContext, exportedCalendarBooking); CalendarBooking importedCalendarBooking = (CalendarBooking) getStagedModel( exportedCalendarBooking.getUuid(), liveGroup); List<CalendarBooking> importedCalendarBookingInstances = CalendarBookingLocalServiceUtil .getRecurringCalendarBookings(importedCalendarBooking); CalendarBookingModel importedCalendarBookingInstance = importedCalendarBookingInstances.get(0); Assert.assertNotEquals(calendarBooking.getCalendarBookingId(), importedCalendarBookingInstance.getRecurringCalendarBookingId()); Assert.assertEquals(importedCalendarBooking.getCalendarBookingId(), importedCalendarBookingInstance.getRecurringCalendarBookingId()); }
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); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCalendarBookingWithAllRecurringInstances() 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; CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance( _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), RandomTestUtil.randomLocaleStringMap(), calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); CalendarBookingLocalServiceUtil.deleteCalendarBooking(calendarBooking, true); calendarBookingInstance = CalendarBookingLocalServiceUtil .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId()); Assert.assertNull(calendarBookingInstance); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testDeleteCalendarBookingWithoutAllRecurringInstances() 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, false); 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 testGetRecurringCalendarBookings() 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); Map<Locale, String> instanceTitleMap = RandomTestUtil.randomLocaleStringMap(); int instanceIndex = 2; long instanceStartTime = startTime + Time.DAY * instanceIndex; CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(_user.getUserId(), calendarBooking.getCalendarBookingId(), instanceIndex, calendar.getCalendarId(), instanceTitleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); instanceIndex = 4;// w w w .j a v a 2 s.com instanceStartTime = instanceStartTime + Time.DAY * instanceStartTime; CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(_user.getUserId(), calendarBooking.getCalendarBookingId(), instanceIndex, calendar.getCalendarId(), instanceTitleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); List<CalendarBooking> instances = CalendarBookingLocalServiceUtil .getRecurringCalendarBookings(calendarBooking); Assert.assertEquals(instances.toString(), 3, instances.size()); for (CalendarBooking instance : instances) { if (instance.getCalendarBookingId() == calendarBooking.getCalendarBookingId()) { continue; } Assert.assertEquals(instanceTitleMap, instance.getTitleMap()); } }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testGetRecurringCalendarBookingsSkipPastEvents() 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); Map<Locale, String> instanceTitleMap = RandomTestUtil.randomLocaleStringMap(); int instanceIndex = 2; long firstInstancStartTime = startTime + Time.DAY * instanceIndex; CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(_user.getUserId(), calendarBooking.getCalendarBookingId(), instanceIndex, calendar.getCalendarId(), instanceTitleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), firstInstancStartTime, firstInstancStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); instanceIndex = 4;// w ww. j ava 2 s .c o m long secondInstancStartTime = firstInstancStartTime + Time.DAY * instanceIndex; CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(_user.getUserId(), calendarBooking.getCalendarBookingId(), instanceIndex, calendar.getCalendarId(), instanceTitleMap, calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), secondInstancStartTime, secondInstancStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext); List<CalendarBooking> instances = CalendarBookingLocalServiceUtil .getRecurringCalendarBookings(calendarBooking, firstInstancStartTime + 1); Assert.assertEquals(instances.toString(), 1, instances.size()); CalendarBooking instance = instances.get(0); Assert.assertEquals(secondInstancStartTime, instance.getStartTime()); }