/**
* 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.dynamic.data.lists.ratings.test;
import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
import com.liferay.dynamic.data.lists.helper.DDLRecordSetTestHelper;
import com.liferay.dynamic.data.lists.helper.DDLRecordTestHelper;
import com.liferay.dynamic.data.lists.model.DDLRecord;
import com.liferay.dynamic.data.lists.model.DDLRecordSet;
import com.liferay.dynamic.data.lists.service.DDLRecordLocalServiceUtil;
import com.liferay.dynamic.data.mapping.model.DDMForm;
import com.liferay.dynamic.data.mapping.model.DDMStructure;
import com.liferay.dynamic.data.mapping.storage.StorageType;
import com.liferay.dynamic.data.mapping.test.util.DDMFormTestUtil;
import com.liferay.dynamic.data.mapping.test.util.DDMStructureTestHelper;
import com.liferay.portal.kernel.model.BaseModel;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.test.rule.AggregateTestRule;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portlet.ratings.test.BaseRatingsTestCase;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
/**
* @author Cristina González
*/
@RunWith(Arquillian.class)
public class DDLRecordRatingsTest extends BaseRatingsTestCase {
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule =
new LiferayIntegrationTestRule();
@Override
protected BaseModel<?> addBaseModel(
BaseModel<?> parentBaseModel, ServiceContext serviceContext)
throws Exception {
DDMForm ddmForm = DDMFormTestUtil.createDDMForm("Field");
Set<Locale> availableLocales = new HashSet<>();
availableLocales.add(LocaleUtil.US);
ddmForm.setAvailableLocales(availableLocales);
ddmForm.setDefaultLocale(LocaleUtil.US);
DDMStructureTestHelper ddmStructureTestHelper =
new DDMStructureTestHelper(
PortalUtil.getClassNameId(DDLRecordSet.class), group);
DDMStructure ddmStructure = ddmStructureTestHelper.addStructure(
ddmForm, StorageType.JSON.toString());
DDLRecordSetTestHelper recordSetTestHelper = new DDLRecordSetTestHelper(
group);
DDLRecordSet recordSet = recordSetTestHelper.addRecordSet(ddmStructure);
DDLRecordTestHelper recordTestHelper = new DDLRecordTestHelper(
group, recordSet);
return recordTestHelper.addRecord();
}
@Override
protected BaseModel<?> deleteBaseModel(
BaseModel<?> baseModel, ServiceContext serviceContext)
throws Exception {
return DDLRecordLocalServiceUtil.deleteRecord((DDLRecord)baseModel);
}
@Override
protected Class<?> getBaseModelClass() {
return DDLRecord.class;
}
}