Example usage for com.liferay.portal.kernel.util DateUtil newTime

List of usage examples for com.liferay.portal.kernel.util DateUtil newTime

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util DateUtil newTime.

Prototype

public static long newTime() 

Source Link

Usage

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

License:Open Source License

protected void addCalendarBooking(LocalizedValuesMap titleMap) {
    try {/*from ww w. ja  v a2  s .  co  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.search.test.CalendarFixture.java

License:Open Source License

public CalendarBooking addCalendarBooking(LocalizedValuesMap titleLocalizedValuesMap, Calendar calendar,
        ServiceContext serviceContext) throws PortalException {

    long startTime = DateUtil.newTime() + RandomTestUtil.randomInt();

    long endTime = startTime + Time.HOUR;

    CalendarBooking calendarBooking = _calendarBookingLocalService.addCalendarBooking(
            serviceContext.getUserId(), calendar.getCalendarId(), new long[0],
            CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, 0, titleLocalizedValuesMap.getValues(),
            Collections.emptyMap(), null, startTime, endTime, false, null, 0, "email", 0, "email",
            serviceContext);/*from   w ww .j  a v  a 2s .c  o  m*/

    _calendarBookings.add(calendarBooking);

    return calendarBooking;
}

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  w w w  .  j  a  va  2 s.c o 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  w  w  .jav  a 2 s. c om*/

    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);//  w  ww  .j  av a2  s  .co  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);//from   ww w  .j  ava  2  s . co  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.upgrade.v1_0_6.test.UpgradeSchemaTest.java

License:Open Source License

protected CalendarBooking addCalendarBooking() throws PortalException {
    Calendar calendar = addCalendar();

    long startTime = DateUtil.newTime();

    return CalendarBookingLocalServiceUtil.addCalendarBooking(_user.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, false, null, 0, null, 0, null,
            ServiceContextTestUtil.getServiceContext());
}