/** * 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.portlet.social.service; import com.liferay.asset.kernel.model.AssetEntry; import com.liferay.portal.kernel.dao.orm.QueryUtil; 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.test.rule.LiferayIntegrationTestRule; import com.liferay.portlet.social.util.SocialActivityHierarchyEntryThreadLocal; import com.liferay.portlet.social.util.test.SocialActivityTestUtil; import com.liferay.social.kernel.model.SocialActivity; import com.liferay.social.kernel.model.SocialActivityConstants; import com.liferay.social.kernel.service.SocialActivityLocalServiceUtil; import java.util.List; import org.junit.Assert; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; /** * @author Zsolt Berentey */ @Sync public class SocialActivityLocalServiceTest extends BaseSocialActivityTestCase { @ClassRule @Rule public static final AggregateTestRule aggregateTestRule = new AggregateTestRule( new LiferayIntegrationTestRule(), SynchronousDestinationTestRule.INSTANCE); @Test public void testActivityHierarchy() throws Exception { AssetEntry parentAssetEntry = SocialActivityTestUtil.addAssetEntry( creatorUser, group); SocialActivityHierarchyEntryThreadLocal.push( parentAssetEntry.getClassNameId(), parentAssetEntry.getClassPK()); SocialActivityTestUtil.addActivity(creatorUser, group, assetEntry, 1); List<SocialActivity> activities = SocialActivityLocalServiceUtil.getGroupActivities( group.getGroupId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS); Assert.assertEquals(activities.toString(), 1, activities.size()); SocialActivity activity = activities.get(0); Assert.assertEquals( parentAssetEntry.getClassNameId(), activity.getParentClassNameId()); Assert.assertEquals( parentAssetEntry.getClassPK(), activity.getParentClassPK()); SocialActivityTestUtil.addActivity( creatorUser, group, assetEntry, SocialActivityConstants.TYPE_DELETE); Assert.assertEquals( 1, SocialActivityLocalServiceUtil.getGroupActivitiesCount( group.getGroupId())); } }