/**
* 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.blogs.internal.exportimport.test;
import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
import com.liferay.blogs.model.BlogsEntry;
import com.liferay.blogs.service.BlogsEntryLocalServiceUtil;
import com.liferay.blogs.web.constants.BlogsPortletKeys;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.StagedModel;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.test.rule.AggregateTestRule;
import com.liferay.portal.kernel.test.rule.Sync;
import com.liferay.portal.kernel.test.rule.SynchronousDestinationTestRule;
import com.liferay.portal.kernel.test.util.RandomTestUtil;
import com.liferay.portal.kernel.test.util.ServiceContextTestUtil;
import com.liferay.portal.kernel.test.util.TestPropsValues;
import com.liferay.portal.lar.test.BasePortletExportImportTestCase;
import com.liferay.portal.service.test.ServiceTestUtil;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import java.util.Date;
import java.util.Map;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
/**
* @author Juan Fernández
*/
@RunWith(Arquillian.class)
@Sync
public class BlogsExportImportTest extends BasePortletExportImportTestCase {
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule =
new AggregateTestRule(
new LiferayIntegrationTestRule(),
SynchronousDestinationTestRule.INSTANCE);
@Override
public String getNamespace() {
return "blogs";
}
@Override
public String getPortletId() {
return BlogsPortletKeys.BLOGS;
}
@Before
@Override
public void setUp() throws Exception {
super.setUp();
ServiceTestUtil.setUser(TestPropsValues.getUser());
}
@Override
protected StagedModel addStagedModel(long groupId) throws Exception {
ServiceContext serviceContext =
ServiceContextTestUtil.getServiceContext(
groupId, TestPropsValues.getUserId());
return BlogsEntryLocalServiceUtil.addEntry(
TestPropsValues.getUserId(), RandomTestUtil.randomString(),
RandomTestUtil.randomString(), serviceContext);
}
@Override
protected StagedModel addStagedModel(long groupId, Date createdDate)
throws Exception {
ServiceContext serviceContext =
ServiceContextTestUtil.getServiceContext(
groupId, TestPropsValues.getUserId());
serviceContext.setCreateDate(createdDate);
serviceContext.setModifiedDate(createdDate);
BlogsEntry entry = BlogsEntryLocalServiceUtil.addEntry(
TestPropsValues.getUserId(), RandomTestUtil.randomString(),
RandomTestUtil.randomString(), serviceContext);
return entry;
}
@Override
protected void deleteStagedModel(StagedModel stagedModel) throws Exception {
BlogsEntryLocalServiceUtil.deleteEntry((BlogsEntry)stagedModel);
}
@Override
protected Map<String, String[]> getExportParameterMap() throws Exception {
Map<String, String[]> parameterMap = super.getExportParameterMap();
addParameter(parameterMap, "entries", true);
addParameter(parameterMap, "referenced-content", true);
return parameterMap;
}
@Override
protected Map<String, String[]> getImportParameterMap() throws Exception {
Map<String, String[]> parameterMap = super.getImportParameterMap();
addParameter(parameterMap, "entries", true);
addParameter(parameterMap, "referenced-content", true);
return parameterMap;
}
@Override
protected StagedModel getStagedModel(String uuid, long groupId)
throws PortalException {
return BlogsEntryLocalServiceUtil.getBlogsEntryByUuidAndGroupId(
uuid, groupId);
}
}