/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.calendar.ratings.test; import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian; import com.liferay.calendar.model.Calendar; import com.liferay.calendar.model.CalendarBooking; import com.liferay.calendar.model.CalendarBookingConstants; import com.liferay.calendar.model.CalendarResource; import com.liferay.calendar.service.CalendarBookingLocalServiceUtil; import com.liferay.calendar.util.CalendarResourceUtil; import com.liferay.portal.kernel.model.BaseModel; import com.liferay.portal.kernel.model.Group; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.test.rule.AggregateTestRule; import com.liferay.portal.kernel.test.util.RandomTestUtil; import com.liferay.portal.kernel.test.util.TestPropsValues; import com.liferay.portal.kernel.util.Time; import com.liferay.portal.test.rule.LiferayIntegrationTestRule; import com.liferay.portlet.ratings.test.BaseRatingsTestCase; import org.junit.ClassRule; import org.junit.Rule; import org.junit.runner.RunWith; /** * @author Cristina González */ @RunWith(Arquillian.class) public class CalendarBookingRatingsTest extends BaseRatingsTestCase { @ClassRule @Rule public static final AggregateTestRule aggregateTestRule = new LiferayIntegrationTestRule(); @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); } @Override protected BaseModel<?> deleteBaseModel( BaseModel<?> baseModel, ServiceContext serviceContext) throws Exception { return CalendarBookingLocalServiceUtil.deleteCalendarBooking( (CalendarBooking)baseModel); } @Override protected Class<?> getBaseModelClass() { return CalendarBooking.class; } @Override protected BaseModel<?> getParentBaseModel( Group group, ServiceContext serviceContext) throws Exception { CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource( TestPropsValues.getUserId(), serviceContext); return calendarResource.getDefaultCalendar(); } }