/**
* 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.journal.social.test;
import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
import com.liferay.journal.constants.JournalPortletKeys;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.model.JournalFolderConstants;
import com.liferay.journal.service.JournalFolderLocalServiceUtil;
import com.liferay.journal.test.util.JournalTestUtil;
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.TestPropsValues;
import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portlet.social.test.BaseSocialActivityInterpreterTestCase;
import com.liferay.social.kernel.model.SocialActivityConstants;
import com.liferay.social.kernel.model.SocialActivityInterpreter;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
/**
* @author Zsolt Berentey
*/
@RunWith(Arquillian.class)
@Sync
public class JournalFolderActivityInterpreterTest
extends BaseSocialActivityInterpreterTestCase {
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule =
new AggregateTestRule(
new LiferayIntegrationTestRule(),
SynchronousDestinationTestRule.INSTANCE);
@Override
protected void addActivities() throws Exception {
_folder = JournalTestUtil.addFolder(
group.getGroupId(), RandomTestUtil.randomString());
JournalFolderLocalServiceUtil.moveFolderToTrash(
TestPropsValues.getUserId(), _folder.getFolderId());
JournalFolderLocalServiceUtil.restoreFolderFromTrash(
TestPropsValues.getUserId(), _folder.getFolderId());
}
@Override
protected SocialActivityInterpreter getActivityInterpreter() {
return getActivityInterpreter(
JournalPortletKeys.JOURNAL, JournalFolder.class.getName());
}
@Override
protected int[] getActivityTypes() {
return new int[] {
SocialActivityConstants.TYPE_MOVE_TO_TRASH,
SocialActivityConstants.TYPE_RESTORE_FROM_TRASH
};
}
@Override
protected void moveModelsToTrash() throws Exception {
JournalFolderLocalServiceUtil.moveFolderToTrash(
TestPropsValues.getUserId(), _folder.getFolderId());
}
@Override
protected void renameModels() throws Exception {
serviceContext.setCommand(Constants.UPDATE);
JournalFolderLocalServiceUtil.updateFolder(
TestPropsValues.getUserId(), serviceContext.getScopeGroupId(),
_folder.getFolderId(),
JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
RandomTestUtil.randomString(), RandomTestUtil.randomString(), false,
serviceContext);
}
@Override
protected void restoreModelsFromTrash() throws Exception {
JournalFolderLocalServiceUtil.restoreFolderFromTrash(
TestPropsValues.getUserId(), _folder.getFolderId());
}
private JournalFolder _folder;
}