@Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    SocialActivitySet newSocialActivitySet = _persistence.create(pk);

    newSocialActivitySet.setGroupId(RandomTestUtil.nextLong());

    newSocialActivitySet.setCompanyId(RandomTestUtil.nextLong());

    newSocialActivitySet.setUserId(RandomTestUtil.nextLong());

    newSocialActivitySet.setCreateDate(RandomTestUtil.nextLong());

    newSocialActivitySet.setModifiedDate(RandomTestUtil.nextLong());

    newSocialActivitySet.setClassNameId(RandomTestUtil.nextLong());

    newSocialActivitySet.setClassPK(RandomTestUtil.nextLong());

    newSocialActivitySet.setType(RandomTestUtil.nextInt());

    newSocialActivitySet.setExtraData(RandomTestUtil.randomString());

    newSocialActivitySet.setActivityCount(RandomTestUtil.nextInt());

    _socialActivitySets.add(_persistence.update(newSocialActivitySet));

    SocialActivitySet existingSocialActivitySet =
        _persistence.findByPrimaryKey(newSocialActivitySet.getPrimaryKey());

    Assert.assertEquals(
        existingSocialActivitySet.getActivitySetId(), newSocialActivitySet.getActivitySetId());
    Assert.assertEquals(existingSocialActivitySet.getGroupId(), newSocialActivitySet.getGroupId());
    Assert.assertEquals(
        existingSocialActivitySet.getCompanyId(), newSocialActivitySet.getCompanyId());
    Assert.assertEquals(existingSocialActivitySet.getUserId(), newSocialActivitySet.getUserId());
    Assert.assertEquals(
        existingSocialActivitySet.getCreateDate(), newSocialActivitySet.getCreateDate());
    Assert.assertEquals(
        existingSocialActivitySet.getModifiedDate(), newSocialActivitySet.getModifiedDate());
    Assert.assertEquals(
        existingSocialActivitySet.getClassNameId(), newSocialActivitySet.getClassNameId());
    Assert.assertEquals(existingSocialActivitySet.getClassPK(), newSocialActivitySet.getClassPK());
    Assert.assertEquals(existingSocialActivitySet.getType(), newSocialActivitySet.getType());
    Assert.assertEquals(
        existingSocialActivitySet.getExtraData(), newSocialActivitySet.getExtraData());
    Assert.assertEquals(
        existingSocialActivitySet.getActivityCount(), newSocialActivitySet.getActivityCount());
  }
  @Override
  protected String getBody(SocialActivitySet activitySet, ServiceContext serviceContext)
      throws Exception {

    if (activitySet.getType() == SocialActivityKeyConstants.DL_UPDATE_FILE_ENTRY) {

      return getBody(activitySet.getClassName(), activitySet.getClassPK(), serviceContext);
    }

    return super.getBody(activitySet, serviceContext);
  }
  @Override
  protected String getTitlePattern(String groupName, SocialActivitySet activitySet)
      throws Exception {

    String titlePattern = StringPool.BLANK;

    if (activitySet.getType() == SocialActivityKeyConstants.DL_ADD_FILE_ENTRY) {

      titlePattern = "uploaded-x-new-documents";
    } else if (activitySet.getType() == SocialActivityKeyConstants.DL_UPDATE_FILE_ENTRY) {

      titlePattern = "made-x-updates-to-a-document";

      FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(activitySet.getClassPK());

      if (fileEntry.getFolderId() > 0) {
        titlePattern = titlePattern.concat("-in-the-x-folder");
      }
    } else {
      return StringPool.BLANK;
    }

    return titlePattern;
  }
  @Override
  protected Object[] getTitleArguments(
      String groupName,
      SocialActivitySet activitySet,
      String link,
      String title,
      ServiceContext serviceContext)
      throws Exception {

    int activityCount = activitySet.getActivityCount();

    if (activitySet.getType() == SocialActivityKeyConstants.DL_UPDATE_FILE_ENTRY) {

      String folderLink = getFolderLink(activitySet.getClassPK(), serviceContext);

      if (Validator.isNotNull(folderLink)) {
        return new Object[] {activityCount, folderLink};
      }
    }

    return new Object[] {activityCount};
  }