/** * 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.bookmarks.internal.exportimport.test; import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian; import com.liferay.bookmarks.constants.BookmarksPortletKeys; import com.liferay.bookmarks.model.BookmarksEntry; import com.liferay.bookmarks.model.BookmarksFolderConstants; import com.liferay.bookmarks.service.BookmarksEntryLocalServiceUtil; import com.liferay.bookmarks.util.test.BookmarksTestUtil; 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.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 BookmarksExportImportTest extends BasePortletExportImportTestCase { @ClassRule @Rule public static final AggregateTestRule aggregateTestRule = new AggregateTestRule( new LiferayIntegrationTestRule(), SynchronousDestinationTestRule.INSTANCE); @Override public String getNamespace() { return "bookmarks"; } @Override public String getPortletId() { return BookmarksPortletKeys.BOOKMARKS; } @Before @Override public void setUp() throws Exception { ServiceTestUtil.setUser(TestPropsValues.getUser()); super.setUp(); } @Override protected StagedModel addStagedModel(long groupId) throws Exception { return BookmarksTestUtil.addEntry(groupId, true); } @Override protected StagedModel addStagedModel(long groupId, Date createdDate) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(groupId); serviceContext.setCreateDate(createdDate); serviceContext.setModifiedDate(createdDate); return BookmarksTestUtil.addEntry( BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID, true, serviceContext); } @Override protected void deleteStagedModel(StagedModel stagedModel) throws Exception { BookmarksEntryLocalServiceUtil.deleteEntry((BookmarksEntry)stagedModel); } @Override protected Map<String, String[]> getExportParameterMap() throws Exception { Map<String, String[]> parameterMap = super.getExportParameterMap(); addParameter(parameterMap, "entries", true); return parameterMap; } @Override protected Map<String, String[]> getImportParameterMap() throws Exception { Map<String, String[]> parameterMap = super.getImportParameterMap(); addParameter(parameterMap, "entries", true); return parameterMap; } @Override protected StagedModel getStagedModel(String uuid, long groupId) throws PortalException { return BookmarksEntryLocalServiceUtil.getBookmarksEntryByUuidAndGroupId( uuid, groupId); } }