Created
June 22, 2011 07:46
-
-
Save hoatle/1039659 to your computer and use it in GitHub Desktop.
ActivityManager apis and unit test cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2003-2010 eXo Platform SAS. | |
* | |
* This program is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU Affero General Public License | |
* as published by the Free Software Foundation; either version 3 | |
* of the License, or (at your option) any later version. | |
* | |
* This program 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 General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program; if not, see<http:www.gnu.org/licenses/>. | |
*/ | |
package org.exoplatform.social.core.manager; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import org.exoplatform.services.log.ExoLogger; | |
import org.exoplatform.services.log.Log; | |
import org.exoplatform.social.common.RealtimeListAccess; | |
import org.exoplatform.social.core.activity.model.ExoSocialActivity; | |
import org.exoplatform.social.core.activity.model.ExoSocialActivityImpl; | |
import org.exoplatform.social.core.identity.model.Identity; | |
import org.exoplatform.social.core.identity.provider.OrganizationIdentityProvider; | |
import org.exoplatform.social.core.identity.provider.SpaceIdentityProvider; | |
import org.exoplatform.social.core.relationship.model.Relationship; | |
import org.exoplatform.social.core.space.impl.DefaultSpaceApplicationHandler; | |
import org.exoplatform.social.core.space.model.Space; | |
import org.exoplatform.social.core.space.spi.SpaceService; | |
import org.exoplatform.social.core.storage.ActivityStorageException; | |
import org.exoplatform.social.core.test.AbstractCoreTest; | |
/** | |
* Unit Test for {@link ActivityManager}, including cache tests. | |
* @author hoat_le | |
*/ | |
public class ActivityManagerTest extends AbstractCoreTest { | |
private final Log LOG = ExoLogger.getLogger(ActivityManagerTest.class); | |
private List<ExoSocialActivity> tearDownActivityList; | |
private Identity rootIdentity; | |
private Identity johnIdentity; | |
private Identity maryIdentity; | |
private Identity demoIdentity; | |
private IdentityManager identityManager; | |
private RelationshipManager relationshipManager; | |
private ActivityManager activityManager; | |
private SpaceService spaceService; | |
@Override | |
public void setUp() throws Exception { | |
super.setUp(); | |
identityManager = (IdentityManager) getContainer().getComponentInstanceOfType(IdentityManager.class); | |
activityManager = (ActivityManager) getContainer().getComponentInstanceOfType(ActivityManager.class); | |
relationshipManager = (RelationshipManager) getContainer().getComponentInstanceOfType(RelationshipManager.class); | |
spaceService = (SpaceService) getContainer().getComponentInstanceOfType(SpaceService.class); | |
tearDownActivityList = new ArrayList<ExoSocialActivity>(); | |
rootIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "root", false); | |
johnIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "john", false); | |
maryIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "mary", false); | |
demoIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, "demo", false); | |
} | |
@Override | |
public void tearDown() throws Exception { | |
for (ExoSocialActivity activity : tearDownActivityList) { | |
try { | |
activityManager.deleteActivity(activity.getId()); | |
} catch (Exception e) { | |
LOG.warn("can not delete activity with id: " + activity.getId()); | |
} | |
} | |
identityManager.deleteIdentity(rootIdentity); | |
identityManager.deleteIdentity(johnIdentity); | |
identityManager.deleteIdentity(maryIdentity); | |
identityManager.deleteIdentity(demoIdentity); | |
super.tearDown(); | |
} | |
/** | |
* Test {@link ActivityManager#saveActivityNoReturn(Identity, ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testSaveActivityNoReturn() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
} | |
/** | |
* Test {@link ActivityManager#saveActivity(ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testSaveActivityNoReturnNotStreamOwner() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(activity); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
} | |
/** | |
* Test for {@link ActivityManager#saveActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity)} | |
* and {@link ActivityManager#saveActivity(Identity, org.exoplatform.social.core.activity.model.ExoSocialActivity)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testSaveActivity() throws ActivityStorageException { | |
//save mal-formed activity | |
{ | |
ExoSocialActivity malformedActivity = new ExoSocialActivityImpl();; | |
malformedActivity.setTitle("malform"); | |
try { | |
activityManager.saveActivity(malformedActivity); | |
fail("Expecting IllegalArgumentException."); | |
} catch (IllegalArgumentException e) { | |
LOG.info("test with malfomred activity passes."); | |
} | |
} | |
{ | |
final String activityTitle = "root activity"; | |
ExoSocialActivity rootActivity = new ExoSocialActivityImpl(); | |
rootActivity.setTitle(activityTitle); | |
rootActivity.setUserId(rootIdentity.getId()); | |
activityManager.saveActivity(rootActivity); | |
assertNotNull("rootActivity.getId() must not be null", rootActivity.getId()); | |
//updates | |
rootActivity.setTitle("Hello World"); | |
activityManager.updateActivity(rootActivity); | |
tearDownActivityList.add(rootActivity); | |
} | |
{ | |
final String title = "john activity"; | |
ExoSocialActivity johnActivity = new ExoSocialActivityImpl(); | |
johnActivity.setTitle(title); | |
activityManager.saveActivity(johnIdentity, johnActivity); | |
tearDownActivityList.add(johnActivity); | |
assertNotNull("johnActivity.getId() must not be null", johnActivity.getId()); | |
} | |
} | |
/** | |
* Test {@link ActivityManager#saveActivity(Identity, ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testSaveActivityWithStreamOwner() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = demoIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivity(demoIdentity, activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
tearDownActivityList.add(activity); | |
} | |
/** | |
* Test {@link ActivityManager#getActivities(Identity, long, long)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivitiesWithOffsetLimit() throws Exception { | |
this.populateActivityMass(johnIdentity, 10); | |
List<ExoSocialActivity> johnActivities = activityManager.getActivities(johnIdentity, 0, 5); | |
assertNotNull("johnActivities must not be null", johnActivities); | |
assertEquals("johnActivities.size() must return: 5", 5, johnActivities.size()); | |
johnActivities = activityManager.getActivities(johnIdentity, 0, 10); | |
assertNotNull("johnActivities must not be null", johnActivities); | |
assertEquals("johnActivities.size() must return: 0", 10, johnActivities.size()); | |
johnActivities = activityManager.getActivities(johnIdentity, 0, 20); | |
assertNotNull("johnActivities must not be null", johnActivities); | |
assertEquals("johnActivities.size() must return: 10", 10, johnActivities.size()); | |
} | |
/** | |
* Test {@link ActivityManager#getActivity(String)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetActivity() throws ActivityStorageException { | |
List<ExoSocialActivity> rootActivities = activityManager.getActivities(rootIdentity); | |
assertEquals("user's activities should have 0 element.", 0, rootActivities.size()); | |
String activityTitle = "title"; | |
String userId = rootIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(rootIdentity, activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
rootActivities = activityManager.getActivities(rootIdentity); | |
assertEquals("user's activities should have 1 element", 1, rootActivities.size()); | |
tearDownActivityList.addAll(rootActivities); | |
} | |
/** | |
* Tests {@link ActivityManager#getParentActivity(ExoSocialActivity)}. | |
*/ | |
public void testGetParentActivity() { | |
populateActivityMass(demoIdentity, 1); | |
ExoSocialActivity demoActivity = activityManager.getActivitiesWithListAccess(demoIdentity).load(0, 1)[0]; | |
assertNotNull("demoActivity must be false", demoActivity); | |
try { | |
activityManager.getParentActivity(demoActivity); | |
fail("Expecting NullPointerException"); | |
} catch (NullPointerException npe) { | |
} | |
//comment | |
ExoSocialActivityImpl comment = new ExoSocialActivityImpl(); | |
comment.setTitle("comment"); | |
comment.setUserId(demoIdentity.getId()); | |
activityManager.saveComment(demoActivity, comment); | |
ExoSocialActivity gotComment = activityManager.getCommentsWithListAccess(demoActivity).load(0, 1)[0]; | |
assertNotNull("gotComment must not be null", gotComment); | |
ExoSocialActivity parentActivity = activityManager.getParentActivity(gotComment); | |
assertNotNull("parentActivity must not be null", parentActivity); | |
assertEquals("parentActivity.getId() must return: " + demoActivity.getId(), | |
demoActivity.getId(), | |
parentActivity.getId()); | |
assertEquals("parentActivity.getTitle() must return: " + demoActivity.getTitle(), | |
demoActivity.getTitle(), | |
parentActivity.getTitle()); | |
assertEquals("parentActivity.getUserId() must return: " + demoActivity.getUserId(), | |
demoActivity.getUserId(), | |
parentActivity.getUserId()); | |
} | |
/** | |
* Test {@link ActivityManager#updateActivity(ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testUpdateActivity() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
String newTitle = "new activity title"; | |
activity.setTitle(newTitle); | |
activityManager.updateActivity(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + newTitle, newTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
} | |
/** | |
* Unit Test for: | |
* <p> | |
* {@link ActivityManager#deleteActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity)} | |
* | |
* @throws Exception | |
*/ | |
public void testDeleteActivity() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
activityManager.deleteActivity(activity); | |
} | |
/** | |
* Test {@link ActivityManager#deleteActivity(String)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testDeleteActivityWithId() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
activityManager.deleteActivity(activity.getId()); | |
} | |
/** | |
* Test {@link ActivityManager#saveComment(ExoSocialActivity, ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testSaveComment() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = johnIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
tearDownActivityList.add(activity); | |
String commentTitle = "Comment title"; | |
//demo comments on john's activity | |
ExoSocialActivity comment = new ExoSocialActivityImpl(); | |
comment.setTitle(commentTitle); | |
comment.setUserId(demoIdentity.getId()); | |
activityManager.saveComment(activity, comment); | |
List<ExoSocialActivity> demoComments = activityManager.getComments(activity); | |
assertNotNull("demoComments must not be null", demoComments); | |
assertEquals("demoComments.size() must return: 1", 1, demoComments.size()); | |
assertEquals("demoComments.get(0).getTitle() must return: " + commentTitle, | |
commentTitle, demoComments.get(0).getTitle()); | |
assertEquals("demoComments.get(0).getUserId() must return: " + demoIdentity.getId(), demoIdentity.getId(), demoComments.get(0).getUserId()); | |
ExoSocialActivity gotParentActivity = activityManager.getParentActivity(demoComments.get(0)); | |
//assertTrue("demoComments.get(0).isComment() must be true", demoComments.get(0).isComment()); | |
//assertFalse("gotParentActivity.isComment() must be false", gotParentActivity.isComment()); | |
assertNotNull(gotParentActivity); | |
assertEquals(activity.getId(), gotParentActivity.getId()); | |
assertEquals(1, activity.getReplyToId().length); | |
assertEquals(comment.getId(), activity.getReplyToId()[0]); | |
} | |
/** | |
* Test {@link ActivityManager#getCommentsWithListAccess(ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetCommentsWithListAccess() throws Exception { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
int total = 10; | |
ExoSocialActivity baseActivity = new ExoSocialActivityImpl(); | |
for (int i = 0; i < total; i ++) { | |
ExoSocialActivity maryComment = new ExoSocialActivityImpl(); | |
maryComment.setUserId(maryIdentity.getId()); | |
maryComment.setTitle("mary comment"); | |
activityManager.saveComment(demoActivity, maryComment); | |
if (i == 5) { | |
baseActivity = maryComment; | |
} | |
} | |
RealtimeListAccess<ExoSocialActivity> maryComments = activityManager.getCommentsWithListAccess(demoActivity); | |
assertNotNull("maryComments must not be null", maryComments); | |
assertEquals("maryComments.getSize() must return: 10", total, maryComments.getSize()); | |
assertEquals("maryComments.getNumberOfNewer(baseActivity, 10) must return: 5", 5, | |
maryComments.getNumberOfNewer(baseActivity)); | |
assertEquals("maryComments.getNumberOfOlder(baseActivity) must return: 4", 4, | |
maryComments.getNumberOfOlder(baseActivity)); | |
} | |
/** | |
* Test {@link ActivityManager#deleteComment(ExoSocialActivity, ExoSocialActivity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testDeleteComment() throws Exception { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
ExoSocialActivity maryComment = new ExoSocialActivityImpl(); | |
maryComment.setTitle("mary comment"); | |
maryComment.setUserId(maryIdentity.getId()); | |
activityManager.saveComment(demoActivity, maryComment); | |
activityManager.deleteComment(demoActivity, maryComment); | |
assertEquals("activityManager.getComments(demoActivity).size() must return: 0", 0, activityManager.getComments(demoActivity).size()); | |
} | |
/** | |
* Test {@link ActivityManager#saveLike(ExoSocialActivity, Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3s | |
*/ | |
public void testSaveLike() throws Exception { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertNull("demoActivity.getLikeIdentityIds() must be null", demoActivity.getLikeIdentityIds()); | |
activityManager.saveLike(demoActivity, johnIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 1", 1, demoActivity.getLikeIdentityIds().length); | |
} | |
/** | |
* Test {@link ActivityManager#deleteLike(ExoSocialActivity, Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testDeleteLike() throws Exception { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertNull("demoActivity.getLikeIdentityIds() must be null", demoActivity.getLikeIdentityIds()); | |
activityManager.saveLike(demoActivity, johnIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 1", 1, demoActivity.getLikeIdentityIds().length); | |
activityManager.deleteLike(demoActivity, johnIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
activityManager.deleteLike(demoActivity, maryIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
activityManager.deleteLike(demoActivity, rootIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
} | |
/** | |
* Test {@link ActivityManager#getActivitiesWithListAccess(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivitiesWithListAccess() throws Exception { | |
int total = 10; | |
ExoSocialActivity baseActivity = null; | |
for (int i = 0; i < total; i ++) { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
if (i == 5) { | |
baseActivity = demoActivity; | |
} | |
} | |
this.populateActivityMass(maryIdentity, total); | |
RealtimeListAccess<ExoSocialActivity> demoListAccess = activityManager.getActivitiesWithListAccess(demoIdentity); | |
assertNotNull("demoListAccess must not be null", demoListAccess); | |
assertEquals("demoListAccess.getSize() must return: 10", 10, demoListAccess.getSize()); | |
assertEquals("demoListAccess.getNumberOfNewer(baseActivity) must return: 4", 4, | |
demoListAccess.getNumberOfNewer(baseActivity)); | |
assertEquals("demoListAccess.getNumberOfOlder(baseActivity) must return: 5", 5, | |
demoListAccess.getNumberOfOlder(baseActivity)); | |
} | |
/** | |
* Test {@link ActivityManager#getActivitiesOfConnectionsWithListAccess(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivitiesOfConnectionsWithListAccess() throws Exception { | |
ExoSocialActivity baseActivity = null; | |
for (int i = 0; i < 10; i ++) { | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("activity title " + i); | |
activity.setUserId(johnIdentity.getId()); | |
activityManager.saveActivityNoReturn(johnIdentity, activity); | |
tearDownActivityList.add(activity); | |
if (i == 5) { | |
baseActivity = activity; | |
} | |
} | |
RealtimeListAccess<ExoSocialActivity> demoConnectionActivities = activityManager.getActivitiesOfConnectionsWithListAccess(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.getSize() must return: 0", 0, demoConnectionActivities.getSize()); | |
Relationship demoJohnRelationship = relationshipManager.invite(demoIdentity, johnIdentity); | |
relationshipManager.confirm(demoJohnRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnectionsWithListAccess(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.getSize() must return: 10", 10, demoConnectionActivities.getSize()); | |
assertEquals("demoConnectionActivities.getNumberOfNewer(baseActivity)", 4, | |
demoConnectionActivities.getNumberOfNewer(baseActivity)); | |
assertEquals("demoConnectionActivities.getNumberOfOlder(baseActivity) must return: 5", 5, | |
demoConnectionActivities.getNumberOfOlder(baseActivity)); | |
for (int i = 0; i < 10; i ++) { | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("activity title " + i); | |
activity.setUserId(maryIdentity.getId()); | |
activityManager.saveActivityNoReturn(maryIdentity, activity); | |
tearDownActivityList.add(activity); | |
if (i == 5) { | |
baseActivity = activity; | |
} | |
} | |
Relationship demoMaryRelationship = relationshipManager.invite(demoIdentity, maryIdentity); | |
relationshipManager.confirm(demoMaryRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnectionsWithListAccess(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.getSize() must return: 20", 20, demoConnectionActivities.getSize()); | |
assertEquals("demoConnectionActivities.getNumberOfNewer(baseActivity)", 4, | |
demoConnectionActivities.getNumberOfNewer(baseActivity)); | |
assertEquals("demoConnectionActivities.getNumberOfOlder(baseActivity) must return: 15", 15, | |
demoConnectionActivities.getNumberOfOlder(baseActivity)); | |
relationshipManager.remove(demoJohnRelationship); | |
relationshipManager.remove(demoMaryRelationship); | |
} | |
/** | |
* Test {@link ActivityManager#getActivitiesOfUserSpacesWithListAccess(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3s | |
*/ | |
public void testGetActivitiesOfUserSpacesWithListAccess() throws Exception { | |
Space space = this.getSpaceInstance(spaceService, 0); | |
Identity spaceIdentity = this.identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName(), false); | |
int totalNumber = 10; | |
ExoSocialActivity baseActivity = null; | |
//demo posts activities to space | |
for (int i = 0; i < totalNumber; i ++) { | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("activity title " + i); | |
activity.setUserId(demoIdentity.getId()); | |
activityManager.saveActivityNoReturn(spaceIdentity, activity); | |
tearDownActivityList.add(activity); | |
if (i == 5) { | |
baseActivity = activity; | |
} | |
} | |
space = spaceService.getSpaceByDisplayName(space.getDisplayName()); | |
assertNotNull("space must not be null", space); | |
assertEquals("space.getDisplayName() must return: my space 0", "my space 0", space.getDisplayName()); | |
assertEquals("space.getDescription() must return: add new space 0", "add new space 0", space.getDescription()); | |
RealtimeListAccess<ExoSocialActivity> demoActivities = activityManager.getActivitiesOfUserSpacesWithListAccess(demoIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.getSize() must return: 10", 10, demoActivities.getSize()); | |
assertEquals("demoActivities.getNumberOfNewer(baseActivity) must return: 4", 4, | |
demoActivities.getNumberOfNewer(baseActivity)); | |
assertEquals("demoActivities.getNumberOfOlder(baseActivity) must return: 5", 5, | |
demoActivities.getNumberOfOlder(baseActivity)); | |
Space space2 = this.getSpaceInstance(spaceService, 1); | |
Identity spaceIdentity2 = this.identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space2.getPrettyName(), false); | |
//demo posts activities to space2 | |
for (int i = 0; i < totalNumber; i ++) { | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("activity title " + i); | |
activity.setUserId(demoIdentity.getId()); | |
activityManager.saveActivityNoReturn(spaceIdentity2, activity); | |
tearDownActivityList.add(activity); | |
if (i == 5) { | |
baseActivity = activity; | |
} | |
} | |
space2 = spaceService.getSpaceByDisplayName(space2.getDisplayName()); | |
assertNotNull("space2 must not be null", space2); | |
assertEquals("space2.getDisplayName() must return: my space 1", "my space 1", space2.getDisplayName()); | |
assertEquals("space2.getDescription() must return: add new space 1", "add new space 1", space2.getDescription()); | |
demoActivities = activityManager.getActivitiesOfUserSpacesWithListAccess(demoIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.getSize() must return: 20", 20, demoActivities.getSize()); | |
assertEquals("demoActivities.getNumberOfNewer(baseActivity) must return 4", 4, | |
demoActivities.getNumberOfNewer(baseActivity)); | |
assertEquals("demoActivities.getNumberOfOlder(baseActivity) must return 15", 15, | |
demoActivities.getNumberOfOlder(baseActivity)); | |
demoActivities = activityManager.getActivitiesOfUserSpacesWithListAccess(johnIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.getSize() must return: 0", 0, demoActivities.getSize()); | |
spaceService.deleteSpace(space); | |
spaceService.deleteSpace(space2); | |
} | |
/** | |
* Test {@link ActivityManager#getActivityFeedWithListAccess(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivityFeedWithListAccess() throws Exception { | |
this.populateActivityMass(demoIdentity, 3); | |
this.populateActivityMass(maryIdentity, 3); | |
this.populateActivityMass(johnIdentity, 2); | |
Space space = this.getSpaceInstance(spaceService, 0); | |
Identity spaceIdentity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName(), false); | |
populateActivityMass(spaceIdentity, 5); | |
RealtimeListAccess<ExoSocialActivity> demoActivityFeed = activityManager.getActivityFeedWithListAccess(demoIdentity); | |
assertEquals("demoActivityFeed.getSize() must be 8", 8, demoActivityFeed.getSize()); | |
Relationship demoMaryConnection = relationshipManager.invite(demoIdentity, maryIdentity); | |
assertEquals(8, activityManager.getActivityFeedWithListAccess(demoIdentity).getSize()); | |
relationshipManager.confirm(demoMaryConnection); | |
RealtimeListAccess<ExoSocialActivity> demoActivityFeed2 = activityManager.getActivityFeedWithListAccess(demoIdentity); | |
assertEquals("demoActivityFeed2.getSize() must return 11", 11, demoActivityFeed2.getSize()); | |
RealtimeListAccess<ExoSocialActivity> maryActivityFeed = activityManager.getActivityFeedWithListAccess(maryIdentity); | |
assertEquals("maryActivityFeed.getSize() must return 6", 6, maryActivityFeed.getSize()); | |
relationshipManager.remove(demoMaryConnection); | |
spaceService.deleteSpace(space); | |
} | |
/** | |
* Test {@link ActivityManager#getComments(ExoSocialActivity)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetCommentWithHtmlContent() throws ActivityStorageException { | |
String htmlString = "<span><strong>foo</strong>bar<script>zed</script></span>"; | |
String htmlRemovedString = "<span><strong>foo</strong>bar<script>zed</script></span>"; | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("blah blah"); | |
activityManager.saveActivity(rootIdentity, activity); | |
ExoSocialActivity comment = new ExoSocialActivityImpl(); | |
comment.setTitle(htmlString); | |
comment.setUserId(rootIdentity.getId()); | |
comment.setBody(htmlString); | |
activityManager.saveComment(activity, comment); | |
assertNotNull("comment.getId() must not be null", comment.getId()); | |
List<ExoSocialActivity> comments = activityManager.getComments(activity); | |
assertEquals(1, comments.size()); | |
assertEquals(htmlRemovedString, comments.get(0).getBody()); | |
assertEquals(htmlRemovedString, comments.get(0).getTitle()); | |
tearDownActivityList.add(activity); | |
} | |
/** | |
* | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetComment() throws ActivityStorageException { | |
ExoSocialActivity activity = new ExoSocialActivityImpl();; | |
activity.setTitle("blah blah"); | |
activityManager.saveActivity(rootIdentity, activity); | |
ExoSocialActivity comment = new ExoSocialActivityImpl();; | |
comment.setTitle("comment blah blah"); | |
comment.setUserId(rootIdentity.getId()); | |
activityManager.saveComment(activity, comment); | |
assertNotNull("comment.getId() must not be null", comment.getId()); | |
String[] commentsId = activity.getReplyToId(); | |
assertEquals(comment.getId(), commentsId[0]); | |
tearDownActivityList.add(activity); | |
} | |
/** | |
* | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetComments() throws ActivityStorageException { | |
ExoSocialActivity activity = new ExoSocialActivityImpl();; | |
activity.setTitle("blah blah"); | |
activityManager.saveActivity(rootIdentity, activity); | |
List<ExoSocialActivity> comments = new ArrayList<ExoSocialActivity>(); | |
for (int i = 0; i < 10; i++) { | |
ExoSocialActivity comment = new ExoSocialActivityImpl();; | |
comment.setTitle("comment blah blah"); | |
comment.setUserId(rootIdentity.getId()); | |
activityManager.saveComment(activity, comment); | |
assertNotNull("comment.getId() must not be null", comment.getId()); | |
comments.add(comment); | |
} | |
ExoSocialActivity assertActivity = activityManager.getActivity(activity.getId()); | |
String[] commentIds = assertActivity.getReplyToId(); | |
for (int i = 1; i < commentIds.length; i++) { | |
assertEquals(comments.get(i - 1).getId(), commentIds[i - 1]); | |
} | |
tearDownActivityList.add(activity); | |
} | |
/** | |
* Unit Test for: | |
* <p> | |
* {@link ActivityManager#deleteComment(String, String)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testDeleteCommentWithId() throws ActivityStorageException { | |
final String title = "Activity Title"; | |
{ | |
//FIXBUG: SOC-1194 | |
//Case: a user create an activity in his stream, then give some comments on it. | |
//Delete comments and check | |
ExoSocialActivity activity1 = new ExoSocialActivityImpl();; | |
activity1.setUserId(demoIdentity.getId()); | |
activity1.setTitle(title); | |
activityManager.saveActivity(demoIdentity, activity1); | |
final int numberOfComments = 10; | |
final String commentTitle = "Activity Comment"; | |
for (int i = 0; i < numberOfComments; i++) { | |
ExoSocialActivity comment = new ExoSocialActivityImpl();; | |
comment.setUserId(demoIdentity.getId()); | |
comment.setTitle(commentTitle + i); | |
activityManager.saveComment(activity1, comment); | |
} | |
List<ExoSocialActivity> storedCommentList = activityManager.getComments(activity1); | |
assertEquals("storedCommentList.size() must return: " + numberOfComments, numberOfComments, storedCommentList.size()); | |
//delete random 2 comments | |
int index1 = new Random().nextInt(numberOfComments - 1); | |
int index2 = index1; | |
while (index2 == index1) { | |
index2 = new Random().nextInt(numberOfComments - 1); | |
} | |
ExoSocialActivity tobeDeletedComment1 = storedCommentList.get(index1); | |
ExoSocialActivity tobeDeletedComment2 = storedCommentList.get(index2); | |
activityManager.deleteComment(activity1.getId(), tobeDeletedComment1.getId()); | |
activityManager.deleteComment(activity1.getId(), tobeDeletedComment2.getId()); | |
List<ExoSocialActivity> afterDeletedCommentList = activityManager.getComments(activity1); | |
assertEquals("afterDeletedCommentList.size() must return: " + (numberOfComments - 2), numberOfComments - 2, afterDeletedCommentList.size()); | |
tearDownActivityList.add(activity1); | |
} | |
} | |
/** | |
* Unit Test for: | |
* {@link ActivityManager#getActivities(Identity)} | |
* {@link ActivityManager#getActivities(Identity, long, long)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetActivities() throws ActivityStorageException { | |
List<ExoSocialActivity> rootActivityList = activityManager.getActivities(rootIdentity); | |
assertNotNull("rootActivityList must not be null", rootActivityList); | |
assertEquals(0, rootActivityList.size()); | |
populateActivityMass(rootIdentity, 30); | |
List<ExoSocialActivity> activities = activityManager.getActivities(rootIdentity); | |
assertNotNull("activities must not be null", activities); | |
assertEquals(20, activities.size()); | |
List<ExoSocialActivity> allActivities = activityManager.getActivities(rootIdentity, 0, 30); | |
assertEquals(30, allActivities.size()); | |
} | |
/** | |
* Unit Test for: | |
* <p> | |
* {@link ActivityManager#getActivitiesOfConnections(Identity)} | |
* | |
* @throws Exception | |
*/ | |
public void testGetActivitiesOfConnections() throws Exception { | |
this.populateActivityMass(johnIdentity, 10); | |
List<ExoSocialActivity> demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 0", 0, demoConnectionActivities.size()); | |
Relationship demoJohnRelationship = relationshipManager.invite(demoIdentity, johnIdentity); | |
relationshipManager.confirm(demoJohnRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 10", 10, demoConnectionActivities.size()); | |
this.populateActivityMass(maryIdentity, 10); | |
Relationship demoMaryRelationship = relationshipManager.invite(demoIdentity, maryIdentity); | |
relationshipManager.confirm(demoMaryRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 20", 20, demoConnectionActivities.size()); | |
relationshipManager.remove(demoJohnRelationship); | |
relationshipManager.remove(demoMaryRelationship); | |
} | |
/** | |
* Test {@link ActivityManager#getActivitiesOfConnections(Identity, int, int)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivitiesOfConnectionswithOffsetLimit() throws Exception { | |
this.populateActivityMass(johnIdentity, 10); | |
List<ExoSocialActivity> demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity, 0, 20); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 0", 0, demoConnectionActivities.size()); | |
Relationship demoJohnRelationship = relationshipManager.invite(demoIdentity, johnIdentity); | |
relationshipManager.confirm(demoJohnRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity, 0, 5); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 5", 5, demoConnectionActivities.size()); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity, 0, 20); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 10", 10, demoConnectionActivities.size()); | |
this.populateActivityMass(maryIdentity, 10); | |
Relationship demoMaryRelationship = relationshipManager.invite(demoIdentity, maryIdentity); | |
relationshipManager.confirm(demoMaryRelationship); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity, 0, 10); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 10", 10, demoConnectionActivities.size()); | |
demoConnectionActivities = activityManager.getActivitiesOfConnections(demoIdentity, 0, 20); | |
assertNotNull("demoConnectionActivities must not be null", demoConnectionActivities); | |
assertEquals("demoConnectionActivities.size() must return: 20", 20, demoConnectionActivities.size()); | |
relationshipManager.remove(demoJohnRelationship); | |
relationshipManager.remove(demoMaryRelationship); | |
} | |
/** | |
* Unit Test for: | |
* <p> | |
* {@link ActivityManager#getActivitiesOfUserSpaces(Identity)} | |
* | |
* @throws Exception | |
*/ | |
public void testGetActivitiesOfUserSpaces() throws Exception { | |
Space space = this.getSpaceInstance(spaceService, 0); | |
Identity spaceIdentity = this.identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName(), false); | |
int totalNumber = 10; | |
this.populateActivityMass(spaceIdentity, totalNumber); | |
List<ExoSocialActivity> demoActivities = activityManager.getActivitiesOfUserSpaces(demoIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.size() must return: 10", 10, demoActivities.size()); | |
Space space2 = this.getSpaceInstance(spaceService, 1); | |
Identity spaceIdentity2 = this.identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space2.getPrettyName(), false); | |
this.populateActivityMass(spaceIdentity2, totalNumber); | |
demoActivities = activityManager.getActivitiesOfUserSpaces(demoIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.size() must return: 20", 20, demoActivities.size()); | |
demoActivities = activityManager.getActivitiesOfUserSpaces(johnIdentity); | |
assertNotNull("demoActivities must not be null", demoActivities); | |
assertEquals("demoActivities.size() must return: 0", 0, demoActivities.size()); | |
spaceService.deleteSpace(space); | |
spaceService.deleteSpace(space2); | |
} | |
/** | |
* Test {@link ActivityManager#getActivities(Identity, long, long)} | |
* | |
* @throws ActivityStorageException | |
*/ | |
public void testGetActivitiesByPagingWithoutCreatingComments() throws ActivityStorageException { | |
final int totalActivityCount = 9; | |
final int retrievedCount = 7; | |
this.populateActivityMass(johnIdentity, totalActivityCount); | |
List<ExoSocialActivity> activities = activityManager.getActivities(johnIdentity, 0, retrievedCount); | |
assertEquals(retrievedCount, activities.size()); | |
} | |
/** | |
* Test {@link ActivityManager#getActivityFeed(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivityFeed() throws Exception { | |
this.populateActivityMass(demoIdentity, 3); | |
this.populateActivityMass(maryIdentity, 3); | |
this.populateActivityMass(johnIdentity, 2); | |
Space space = this.getSpaceInstance(spaceService, 0); | |
Identity spaceIdentity = identityManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, space.getPrettyName(), false); | |
populateActivityMass(spaceIdentity, 5); | |
List<ExoSocialActivity> demoActivityFeed = activityManager.getActivityFeed(demoIdentity); | |
assertEquals("demoActivityFeed.size() must be 8", 8, demoActivityFeed.size()); | |
Relationship demoMaryConnection = relationshipManager.invite(demoIdentity, maryIdentity); | |
assertEquals(8, activityManager.getActivityFeedWithListAccess(demoIdentity).getSize()); | |
relationshipManager.confirm(demoMaryConnection); | |
List<ExoSocialActivity> demoActivityFeed2 = activityManager.getActivityFeed(demoIdentity); | |
assertEquals("demoActivityFeed2.size() must return 11", 11, demoActivityFeed2.size()); | |
List<ExoSocialActivity> maryActivityFeed = activityManager.getActivityFeed(maryIdentity); | |
assertEquals("maryActivityFeed.size() must return 6", 6, maryActivityFeed.size()); | |
relationshipManager.remove(demoMaryConnection); | |
spaceService.deleteSpace(space); | |
} | |
/** | |
* Test {@link ActivityManager#removeLike(ExoSocialActivity, Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testRemoveLike() throws Exception { | |
ExoSocialActivity demoActivity = new ExoSocialActivityImpl(); | |
demoActivity.setTitle("demo activity"); | |
demoActivity.setUserId(demoActivity.getId()); | |
activityManager.saveActivityNoReturn(demoIdentity, demoActivity); | |
tearDownActivityList.add(demoActivity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertNull("demoActivity.getLikeIdentityIds() must be null", demoActivity.getLikeIdentityIds()); | |
activityManager.saveLike(demoActivity, johnIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 1", 1, demoActivity.getLikeIdentityIds().length); | |
activityManager.removeLike(demoActivity, johnIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
activityManager.removeLike(demoActivity, maryIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
activityManager.removeLike(demoActivity, rootIdentity); | |
demoActivity = activityManager.getActivity(demoActivity.getId()); | |
assertEquals("demoActivity.getLikeIdentityIds().length must return: 0", 0, demoActivity.getLikeIdentityIds().length); | |
} | |
/** | |
* Test {@link ActivityManager#recordActivity(Identity, String, String)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testRecordActivityWithTypeTitle() throws Exception { | |
String DEFAULT_ACTIVITY_TYPE = "DEFAULT_ACTIVITY"; | |
String RELATIONSHIP_ACTIVITY_TYPE = "exosocial:relationship"; | |
String DOC_ACTIVITY_TYPE = "DOC_ACTIVITY"; | |
String LINK_ACTIVITY_TYPE = "LINK_ACTIVITY"; | |
String EMOTION_ACTIVITY_TYPE = "EMOTION_ACTIVITY"; | |
String activityTitle = "activity title"; | |
String userId = demoIdentity.getId(); | |
ExoSocialActivity activity = null; | |
activity = activityManager.recordActivity(demoIdentity, DEFAULT_ACTIVITY_TYPE, activityTitle); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + DEFAULT_ACTIVITY_TYPE, DEFAULT_ACTIVITY_TYPE, activity.getType()); | |
activity = activityManager.recordActivity(demoIdentity, RELATIONSHIP_ACTIVITY_TYPE, activityTitle); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + RELATIONSHIP_ACTIVITY_TYPE, RELATIONSHIP_ACTIVITY_TYPE, activity.getType()); | |
activity = activityManager.recordActivity(demoIdentity, DOC_ACTIVITY_TYPE, activityTitle); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + DOC_ACTIVITY_TYPE, DOC_ACTIVITY_TYPE, activity.getType()); | |
activity = activityManager.recordActivity(demoIdentity, LINK_ACTIVITY_TYPE, activityTitle); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + LINK_ACTIVITY_TYPE, LINK_ACTIVITY_TYPE, activity.getType()); | |
activity = activityManager.recordActivity(demoIdentity, EMOTION_ACTIVITY_TYPE, activityTitle); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + EMOTION_ACTIVITY_TYPE, EMOTION_ACTIVITY_TYPE, activity.getType()); | |
} | |
/** | |
* Test {@link ActivityManager#recordActivity(Identity, String, String, String)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testRecordActivityWithTypeTitleBody() throws Exception { | |
String DEFAULT_ACTIVITY_TYPE = "DEFAULT_ACTIVITY"; | |
String RELATIONSHIP_ACTIVITY_TYPE = "exosocial:relationship"; | |
String DOC_ACTIVITY_TYPE = "DOC_ACTIVITY"; | |
String LINK_ACTIVITY_TYPE = "LINK_ACTIVITY"; | |
String EMOTION_ACTIVITY_TYPE = "EMOTION_ACTIVITY"; | |
String activityTitle = "activity title"; | |
String userId = demoIdentity.getId(); | |
String activityBody = "activity body"; | |
ExoSocialActivity activity = null; | |
activity = activityManager.recordActivity(demoIdentity, DEFAULT_ACTIVITY_TYPE, activityTitle, activityBody); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + DEFAULT_ACTIVITY_TYPE, DEFAULT_ACTIVITY_TYPE, activity.getType()); | |
assertEquals("activity.getBody() must return: " + activityBody, activityBody, activity.getBody()); | |
activity = activityManager.recordActivity(demoIdentity, RELATIONSHIP_ACTIVITY_TYPE, activityTitle, activityBody); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + RELATIONSHIP_ACTIVITY_TYPE, RELATIONSHIP_ACTIVITY_TYPE, activity.getType()); | |
assertEquals("activity.getBody() must return: " + activityBody, activityBody, activity.getBody()); | |
activity = activityManager.recordActivity(demoIdentity, DOC_ACTIVITY_TYPE, activityTitle, activityBody); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + DOC_ACTIVITY_TYPE, DOC_ACTIVITY_TYPE, activity.getType()); | |
assertEquals("activity.getBody() must return: " + activityBody, activityBody, activity.getBody()); | |
activity = activityManager.recordActivity(demoIdentity, LINK_ACTIVITY_TYPE, activityTitle, activityBody); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + LINK_ACTIVITY_TYPE, LINK_ACTIVITY_TYPE, activity.getType()); | |
assertEquals("activity.getBody() must return: " + activityBody, activityBody, activity.getBody()); | |
activity = activityManager.recordActivity(demoIdentity, EMOTION_ACTIVITY_TYPE, activityTitle, activityBody); | |
tearDownActivityList.add(activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
assertEquals("activity.getType() must return: " + EMOTION_ACTIVITY_TYPE, EMOTION_ACTIVITY_TYPE, activity.getType()); | |
assertEquals("activity.getBody() must return: " + activityBody, activityBody, activity.getBody()); | |
} | |
/** | |
* Test {@link ActivityManager#recordActivity(Identity, ExoSocialActivity))} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testRecordActivity() throws Exception { | |
String activityTitle = "activity title"; | |
String userId = demoIdentity.getId(); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle(activityTitle); | |
activity.setUserId(userId); | |
activityManager.recordActivity(demoIdentity, activity); | |
activity = activityManager.getActivity(activity.getId()); | |
assertNotNull("activity must not be null", activity); | |
assertEquals("activity.getTitle() must return: " + activityTitle, activityTitle, activity.getTitle()); | |
assertEquals("activity.getUserId() must return: " + userId, userId, activity.getUserId()); | |
tearDownActivityList.add(activity); | |
} | |
/** | |
* Test {@link ActivityManager#getActivitiesCount(Identity)} | |
* | |
* @throws Exception | |
* @since 1.2.0-Beta3 | |
*/ | |
public void testGetActivitiesCount() throws Exception { | |
int count = activityManager.getActivitiesCount(rootIdentity); | |
assertEquals("count must be: 0", 0, count); | |
populateActivityMass(rootIdentity, 30); | |
count = activityManager.getActivitiesCount(rootIdentity); | |
assertEquals("count must be: 30", 30, count); | |
} | |
/** | |
* | |
*/ | |
/*public void testAddProviders() { | |
activityManager.addProcessor(new FakeProcessor(10)); | |
activityManager.addProcessor(new FakeProcessor(9)); | |
activityManager.addProcessor(new FakeProcessor(8)); | |
ExoSocialActivity activity = new ExoSocialActivityImpl(); | |
activity.setTitle("Hello"); | |
activityManager.processActivitiy(activity); | |
//just verify that we run in priority order | |
assertEquals("Hello-8-9-10", activity.getTitle()); | |
} | |
class FakeProcessor extends BaseActivityProcessorPlugin { | |
public FakeProcessor(int priority) { | |
super(null); | |
super.priority = priority; | |
} | |
@Override | |
public void processActivity(ExoSocialActivity activity) { | |
activity.setTitle(activity.getTitle() + "-" + priority); | |
} | |
} | |
*/ | |
/** | |
* Populates activity. | |
* | |
* @param user | |
* @param number | |
*/ | |
private void populateActivityMass(Identity user, int number) { | |
for (int i = 0; i < number; i++) { | |
ExoSocialActivity activity = new ExoSocialActivityImpl();; | |
activity.setTitle("title " + i); | |
activity.setUserId(user.getId()); | |
tearDownActivityList.add(activity); | |
try { | |
activityManager.saveActivityNoReturn(user, activity); | |
} catch (Exception e) { | |
LOG.error("can not save activity.", e); | |
} | |
} | |
} | |
/** | |
* Gets an instance of the space. | |
* | |
* @param spaceService | |
* @param number | |
* @return | |
* @throws Exception | |
* @since 1.2.0-GA | |
*/ | |
private Space getSpaceInstance(SpaceService spaceService, int number) throws Exception { | |
Space space = new Space(); | |
space.setDisplayName("my space " + number); | |
space.setRegistration(Space.OPEN); | |
space.setDescription("add new space " + number); | |
space.setType(DefaultSpaceApplicationHandler.NAME); | |
space.setVisibility(Space.PUBLIC); | |
space.setRegistration(Space.VALIDATION); | |
space.setPriority(Space.INTERMEDIATE_PRIORITY); | |
space.setGroupId("/space/space" + number); | |
String[] managers = new String[] {"demo", "tom"}; | |
String[] members = new String[] {"raul", "ghost", "dragon"}; | |
String[] invitedUsers = new String[] {"register1", "mary"}; | |
String[] pendingUsers = new String[] {"jame", "paul", "hacker"}; | |
space.setInvitedUsers(invitedUsers); | |
space.setPendingUsers(pendingUsers); | |
space.setManagers(managers); | |
space.setMembers(members); | |
spaceService.saveSpace(space, true); | |
return space; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2003-2010 eXo Platform SAS. | |
* | |
* This program is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU Affero General Public License | |
* as published by the Free Software Foundation; either version 3 | |
* of the License, or (at your option) any later version. | |
* | |
* This program 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 General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program; if not, see<http://www.gnu.org/licenses/>. | |
*/ | |
package org.exoplatform.social.core.manager; | |
import java.util.List; | |
import org.exoplatform.social.common.RealtimeListAccess; | |
import org.exoplatform.social.core.ActivityProcessor; | |
import org.exoplatform.social.core.BaseActivityProcessorPlugin; | |
import org.exoplatform.social.core.activity.model.ExoSocialActivity; | |
import org.exoplatform.social.core.identity.model.Identity; | |
import org.exoplatform.social.core.storage.ActivityStorageException; | |
/** | |
* Public APIs to manage activities. | |
* | |
* @author <a href="mailto:vien_levan@exoplatform.com">vien_levan</a> | |
* @author <a href="http://hoatle.net">hoatle (hoatlevan at gmail dot com)</a> | |
* @see org.exoplatform.social.core.activity.model.ExoSocialActivity | |
* @see org.exoplatform.social.core.storage.ActivityStorage | |
* @see IdentityManager | |
*/ | |
public interface ActivityManager { | |
/** | |
* Saves a new created activity to a stream. Note that the Activity.userId will be set to the owner's identity if it | |
* has not already set. | |
* | |
* @param streamOwner the activity stream owner | |
* @param newActivity the activity to be saved | |
* @since 1.3.0-GA | |
*/ | |
//void saveActivity(Identity streamOwner, ExoSocialActivity newActivity); | |
/** | |
* Saves a new created activity to a stream. Note that the Activity.userId will be set to the owner's identity if it | |
* has not already set. | |
* | |
* @param streamOwner the activity stream owner | |
* @param newActivity the activity to be saved | |
* @return the saved activity | |
* @since 1.2.0-GA | |
*/ | |
void saveActivityNoReturn(Identity streamOwner, ExoSocialActivity newActivity); | |
/** | |
* Saves a new created activity to the stream of that activity's userId stream. The userId of the created activity | |
* must be set to indicate the owner stream. | |
* | |
* @param newActivity the activity to be saved | |
* @since 1.3.0-GA | |
*/ | |
//void saveActivity(ExoSocialActivity newActivity); | |
/** | |
* Saves a new created activity to the stream of that activity's userId stream. The userId of the created activity | |
* must be set to indicate the owner stream. | |
* | |
* @param newActivity the activity to be saved | |
* @since 1.2.0-GA | |
*/ | |
void saveActivityNoReturn(ExoSocialActivity newActivity); | |
/** | |
* Saves a new activity by indicating the stream owner, the activity type and activityTitle. This is shorthand to save | |
* a new created activity without create a new {@link ExoSocialActivity} instance. | |
* | |
* @param streamOwner the activity stream owner | |
* @param activityType the activity type | |
* @param activityTitle the activity title | |
*/ | |
void saveActivity(Identity streamOwner, String activityType, String activityTitle); | |
/** | |
* Gets an activity by its id. | |
* | |
* @param activityId the activity id | |
* @return the activity matching provided activityId | |
*/ | |
ExoSocialActivity getActivity(String activityId); | |
/** | |
* Gets the activity associated with an existing comment. | |
* | |
* @param comment the existing comment | |
* @return the associated activity | |
* @since 1.2.0-GA | |
*/ | |
ExoSocialActivity getParentActivity(ExoSocialActivity comment); | |
/** | |
* Updates an existing activity. | |
* | |
* @param existingActivity the existing activity | |
* @since 1.2.0-GA | |
*/ | |
void updateActivity(ExoSocialActivity existingActivity); | |
/** | |
* Deletes an existing activity. | |
* | |
* @param existingActivity the existing activity | |
* @since 1.1.1 | |
*/ | |
void deleteActivity(ExoSocialActivity existingActivity); | |
/** | |
* Deletes an activity by its id. | |
* | |
* @param activityId the activity id | |
*/ | |
void deleteActivity(String activityId); | |
/** | |
* Saves a new comment to an existing activity. | |
* | |
* @param existingActivity the existing activity | |
* @param newComment the new comment to be saved | |
*/ | |
void saveComment(ExoSocialActivity existingActivity, ExoSocialActivity newComment); | |
/** | |
* Gets the comments of an existing activity via {@link org.exoplatform.social.common.RealtimeListAccess}. | |
* | |
* @param existingActivity the existing activity | |
* @return the realtime list access for these comments | |
* @since 1.3.0-GA | |
*/ | |
//RealtimeListAccess<ExoSocialActivity> getComments(ExoSocialActivity existingActivity); | |
/** | |
* Gets the comments of an existing activity via {@link org.exoplatform.social.common.RealtimeListAccess}. | |
* | |
* | |
* @param existingActivity the existing activity | |
* @return the real time list access for these comments | |
* @since 1.2.0-GA | |
*/ | |
RealtimeListAccess<ExoSocialActivity> getCommentsWithListAccess(ExoSocialActivity existingActivity); | |
/** | |
* Deletes a existing comment of an existing activity by their ids. | |
* | |
* @param activityId | |
* @param commentId | |
*/ | |
void deleteComment(String activityId, String commentId); | |
/** | |
* Deletes an exising comment of an existing activity. | |
* | |
* @param existingActivity the existing activity | |
* @param existingComment the existing comment | |
* @since 1.2.0-GA | |
*/ | |
void deleteComment(ExoSocialActivity existingActivity, ExoSocialActivity existingComment); | |
/** | |
* Saves a like of an identity to an existing activity. | |
* | |
* @param existingActivity the existing activity | |
* @param identity the existing identity who likes this activity | |
*/ | |
void saveLike(ExoSocialActivity existingActivity, Identity identity); | |
/** | |
* Deletes an existing like of an identity from an existing identity. | |
* | |
* @param existingActivity the existing activity | |
* @param identity the existing identity | |
* @since 1.2.0-GA | |
*/ | |
void deleteLike(ExoSocialActivity existingActivity, Identity identity); | |
/** | |
* Gets the activities posted on the provided activity stream owner via {@link RealtimeListAccess}. | |
* | |
* @param ownerIdentity the provided activity stream owner | |
* @return the real time list access for activities on the provided activity stream owner | |
* @since 1.3.0-GA | |
*/ | |
//RealtimeListAccess<ExoSocialActivity> getActivities(Identity ownerIdentity); | |
/** | |
* Gets the activities posted on the provided activity stream owner via {@link RealtimeListAccess}. | |
* | |
* @param ownerIdentity the provided activity stream owner | |
* @return the real time list access for activities on the provided activity stream owner | |
* @since 1.2.0-GA | |
*/ | |
RealtimeListAccess<ExoSocialActivity> getActivitiesWithListAccess(Identity ownerIdentity); | |
/** | |
* Gets the activities posted by all connections with an existing identity via {@link RealtimeListAccess} | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities posted by all connections with an existing identity | |
* @since 1.3.0-GA | |
*/ | |
//RealtimeListAccess<ExoSocialActivity> getActivitiesOfIdentities(Identity existingIdentity); | |
/** | |
* Gets the activities posted by all connections with an existing identity via {@link RealtimeListAccess} | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities posted by all connections with an existing identity | |
* @since 1.2.0-GA | |
*/ | |
RealtimeListAccess<ExoSocialActivity> getActivitiesOfConnectionsWithListAccess(Identity existingIdentity); | |
/** | |
* Gets the activities posted on all space activity streams in which the provided identity joins via {@link | |
* RealtimeListAccess}. | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities | |
* @since 1.3.0-GA | |
*/ | |
//RealtimeListAccess<ExoSocialActivity> getActivitiesOfUserSpaces(Identity existingIdentity); | |
/** | |
* Gets the activities posted on all space activity streams in which the provided identity joins via {@link | |
* RealtimeListAccess}. | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities | |
* @since 1.2.0-GA | |
*/ | |
RealtimeListAccess<ExoSocialActivity> getActivitiesOfUserSpacesWithListAccess(Identity existingIdentity); | |
/** | |
* Gets all the activities accessible by an existing identity via {@link RealtimeListAccess} | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities | |
* @since 1.3.0-GA | |
*/ | |
//RealtimeListAccess<ExoSocialActivity> getActivityFeed(Identity existingIdentity); | |
/** | |
* Gets all the activities accessible by an existing identity combined as {@link RealtimeListAccess}. | |
* This activity feed will contain all activities from existing identity, his connections and member spaces. | |
* | |
* @param existingIdentity the existing identity | |
* @return the real time list access for activities | |
* @since 1.2.0-GA | |
*/ | |
RealtimeListAccess<ExoSocialActivity> getActivityFeedWithListAccess(Identity existingIdentity); | |
/** | |
* Adds a new activity processor. | |
* | |
* @param newActivityProcessor a new activity processor | |
*/ | |
void addProcessor(ActivityProcessor newActivityProcessor); | |
/** | |
* Adds a new activity processor plugin. | |
* | |
* @param newActivityProcessorPlugin the new activity processor plugin | |
*/ | |
void addProcessorPlugin(BaseActivityProcessorPlugin newActivityProcessorPlugin); | |
/** | |
* Saves a new created activity to a stream. Note that the Activity.userId will be set to the owner's identity if it | |
* has not already set. | |
* | |
* @param streamOwner the activity stream owner | |
* @param newActivity the activity to be saved | |
* @return the saved activity | |
* @deprecated Use {@link #saveActivityNoReturn(Identity, ExoSocialActivity)} instead. | |
* Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
ExoSocialActivity saveActivity(Identity streamOwner, ExoSocialActivity newActivity); | |
/** | |
* Saves a new created activity to the stream of that activity's userId stream. The userId of the created activity | |
* must be set to indicate the owner stream. | |
* | |
* @param newActivity the activity to be saved | |
* @deprecated Use {@link #saveActivityNoReturn(org.exoplatform.social.core.activity.model.ExoSocialActivity)} | |
* instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
ExoSocialActivity saveActivity(ExoSocialActivity newActivity); | |
/** | |
* Gets the latest activities by an identity with the default limit of 20 latest activities. | |
* | |
* @param identity the identity | |
* @return the activities | |
* @see #getActivities(Identity, long, long) | |
* @deprecated Use {@link #getActivitiesWithListAccess(org.exoplatform.social.core.identity.model.Identity)} instead. | |
* Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivities(Identity identity) throws ActivityStorageException; | |
/** | |
* Gets the latest activities by an identity, specifying the start that is an offset index and the limit. | |
* | |
* @param identity the identity | |
* @param start offset index | |
* @param limit | |
* @return the activities | |
* @deprecated Use {@link #getActivitiesWithListAccess(Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivities(Identity identity, long start, long limit) throws ActivityStorageException; | |
/** | |
* Gets activities of connections from an identity. The activities are returned sorted starting from the most recent. | |
* | |
* @param ownerIdentity | |
* @return activityList | |
* @since 1.1.1 | |
* @deprecated Use {@link #getActivitiesOfConnectionsWithListAccess(Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivitiesOfConnections(Identity ownerIdentity) throws ActivityStorageException; | |
/** | |
* Gets activities of connections from an identity. The activities are returned sorted starting from the most recent. | |
* | |
* @param ownerIdentity | |
* @return activityList | |
* @deprecated Use {@link #getActivitiesOfConnectionsWithListAccess(Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivitiesOfConnections(Identity ownerIdentity, | |
int offset, int length) throws ActivityStorageException; | |
/** | |
* Gets the activities from all spaces of a user. | |
* | |
* @param ownerIdentity | |
* @return list of activities | |
* @since 1.1.1 | |
* @deprecated Use {@link #getActivitiesOfUserSpacesWithListAccess(Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivitiesOfUserSpaces(Identity ownerIdentity); | |
/** | |
* Gets the activity feed of an identity. This feed is the combination of all the activities of his own activities, | |
* his connections' activities and his spaces' activities which are returned sorted starting from the most recent. | |
* | |
* @param identity | |
* @return all related activities of identity such as his activities, his connections's activities, his spaces's | |
* activities | |
* @since 1.1.2 | |
* @deprecated Use {@link #getActivityFeedWithListAccess(Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getActivityFeed(Identity identity) throws ActivityStorageException; | |
/** | |
* Removes an identity who likes an activity, if this activity is liked, it will be removed. | |
* | |
* @param activity | |
* @param identity a user who dislikes an activity | |
* @deprecated Use {@link #deleteLike(ExoSocialActivity, Identity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
void removeLike(ExoSocialActivity activity, Identity identity) throws ActivityStorageException; | |
/** | |
* Gets an activity's comment list. | |
* | |
* @param activity | |
* @return commentList | |
* @deprecated Use {@link #getCommentsWithListAccess(ExoSocialActivity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
List<ExoSocialActivity> getComments(ExoSocialActivity activity) throws ActivityStorageException; | |
/** | |
* Records an activity. | |
* | |
* @param owner | |
* @param type | |
* @param title | |
* @return | |
* @throws ActivityStorageException | |
* @since 1.2.0-Beta1 | |
* @deprecated Use {@link #saveActivity(Identity, String, String)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
ExoSocialActivity recordActivity(Identity owner, String type, String title) throws ActivityStorageException; | |
/** | |
* Saves an activity. | |
* | |
* @param owner | |
* @param activity | |
* @return the stored activity | |
* @throws Exception | |
* @deprecated use {@link #saveActivity(Identity, ExoSocialActivity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
ExoSocialActivity recordActivity(Identity owner, ExoSocialActivity activity) throws Exception; | |
/** | |
* Records an activity. | |
* | |
* @param owner the owner of the target stream for this activity | |
* @param type the type of activity which will be used to use custom ui for rendering | |
* @param title the title | |
* @param body the body | |
* @return the stored activity | |
* @deprecated Use {@link #saveActivity(Identity, ExoSocialActivity)} instead. Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
ExoSocialActivity recordActivity(Identity owner, String type, String title, | |
String body) throws ActivityStorageException; | |
/** | |
* Gets the number of activities from a stream owner. | |
* | |
* @param owner | |
* @return the number | |
* @deprecated Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
int getActivitiesCount(Identity owner) throws ActivityStorageException; | |
/** | |
* Does nothing, for backward compatible. | |
* | |
* @param activity | |
* @deprecated Will be removed by 1.3.x | |
*/ | |
@Deprecated | |
void processActivitiy(ExoSocialActivity activity); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment