/** * 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.message.boards.social.test; import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian; import com.liferay.message.boards.kernel.model.MBCategoryConstants; import com.liferay.message.boards.kernel.model.MBMessage; import com.liferay.message.boards.kernel.model.MBMessageConstants; import com.liferay.message.boards.kernel.service.MBMessageLocalServiceUtil; import com.liferay.message.boards.kernel.service.MBThreadLocalServiceUtil; 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.kernel.util.ObjectValuePair; import com.liferay.portal.test.rule.LiferayIntegrationTestRule; import com.liferay.portlet.messageboards.social.MBActivityKeys; import java.io.InputStream; import java.util.Collections; import org.junit.ClassRule; import org.junit.Rule; import org.junit.runner.RunWith; /** * @author Zsolt Berentey */ @RunWith(Arquillian.class) @Sync public class MBMessageActivityInterpreterTest extends BaseMBSocialActivityInterpreterTestCase { @ClassRule @Rule public static final AggregateTestRule aggregateTestRule = new AggregateTestRule( new LiferayIntegrationTestRule(), SynchronousDestinationTestRule.INSTANCE); @Override protected void addActivities() throws Exception { message = addMessage(null); message = addMessage(message); } protected MBMessage addMessage(MBMessage parentMessage) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext( group.getGroupId(), TestPropsValues.getUserId()); long categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID; long parentMessageId = MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID; long threadId = 0; if (parentMessage != null) { categoryId = parentMessage.getCategoryId(); parentMessageId = parentMessage.getMessageId(); threadId = parentMessage.getThreadId(); } return MBMessageLocalServiceUtil.addMessage( TestPropsValues.getUserId(), RandomTestUtil.randomString(), group.getGroupId(), categoryId, threadId, parentMessageId, RandomTestUtil.randomString(), RandomTestUtil.randomString(), MBMessageConstants.DEFAULT_FORMAT, Collections.<ObjectValuePair<String, InputStream>>emptyList(), false, 0.0, false, serviceContext); } @Override protected int[] getActivityTypes() { return new int[] { MBActivityKeys.ADD_MESSAGE, MBActivityKeys.REPLY_MESSAGE }; } @Override protected String getClassName() { return MBMessage.class.getName(); } @Override protected boolean isSupportsRename(String className) { return false; } @Override protected void moveModelsToTrash() throws Exception { MBThreadLocalServiceUtil.moveThreadToTrash( TestPropsValues.getUserId(), message.getThreadId()); } @Override protected void renameModels() throws Exception { } @Override protected void restoreModelsFromTrash() throws Exception { MBThreadLocalServiceUtil.restoreThreadFromTrash( TestPropsValues.getUserId(), message.getThreadId()); } protected MBMessage message; }