protected Team addTeam() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Team team = _persistence.create(pk);

    team.setMvccVersion(RandomTestUtil.nextLong());

    team.setCompanyId(RandomTestUtil.nextLong());

    team.setUserId(RandomTestUtil.nextLong());

    team.setUserName(RandomTestUtil.randomString());

    team.setCreateDate(RandomTestUtil.nextDate());

    team.setModifiedDate(RandomTestUtil.nextDate());

    team.setGroupId(RandomTestUtil.nextLong());

    team.setName(RandomTestUtil.randomString());

    team.setDescription(RandomTestUtil.randomString());

    _teams.add(_persistence.update(team));

    return team;
  }
  @Test
  public void testUpdateAssetWhenUpdatingFileEntry() throws Throwable {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    FileEntry fileEntry =
        DLAppLocalServiceUtil.addFileEntry(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString(),
            ContentTypes.TEXT_PLAIN,
            "Old Title",
            RandomTestUtil.randomString(),
            null,
            RandomTestUtil.randomBytes(),
            serviceContext);

    DLAppLocalServiceUtil.updateFileEntry(
        TestPropsValues.getUserId(),
        fileEntry.getFileEntryId(),
        RandomTestUtil.randomString(),
        ContentTypes.TEXT_PLAIN,
        "New Title",
        RandomTestUtil.randomString(),
        null,
        true,
        RandomTestUtil.randomBytes(),
        serviceContext);

    AssetEntry assetEntry =
        AssetEntryLocalServiceUtil.getEntry(
            DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());

    Assert.assertEquals("New Title", assetEntry.getTitle());
  }
  protected MBBan addMBBan() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan mbBan = _persistence.create(pk);

    mbBan.setUuid(RandomTestUtil.randomString());

    mbBan.setGroupId(RandomTestUtil.nextLong());

    mbBan.setCompanyId(RandomTestUtil.nextLong());

    mbBan.setUserId(RandomTestUtil.nextLong());

    mbBan.setUserName(RandomTestUtil.randomString());

    mbBan.setCreateDate(RandomTestUtil.nextDate());

    mbBan.setModifiedDate(RandomTestUtil.nextDate());

    mbBan.setBanUserId(RandomTestUtil.nextLong());

    _mbBans.add(_persistence.update(mbBan));

    return mbBan;
  }
  @Test
  public void testLocalizedSiteAddFileEntryType() throws Exception {
    Group group = GroupTestUtil.addGroup();

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    Locale locale = LocaleThreadLocal.getSiteDefaultLocale();

    try {
      LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN);

      String name = RandomTestUtil.randomString();
      String description = RandomTestUtil.randomString();
      DDMStructure ddmStructure =
          DDMStructureTestUtil.addStructure(
              DLFileEntry.class.getName(), new Locale[] {LocaleUtil.SPAIN}, LocaleUtil.SPAIN);

      DLFileEntryType dlFileEntryType =
          DLFileEntryTypeLocalServiceUtil.addFileEntryType(
              TestPropsValues.getUserId(),
              group.getGroupId(),
              name,
              description,
              new long[] {ddmStructure.getStructureId()},
              serviceContext);

      Assert.assertEquals(name, dlFileEntryType.getName(LocaleUtil.US, true));
      Assert.assertEquals(description, dlFileEntryType.getDescription(LocaleUtil.US, true));
    } finally {
      LocaleThreadLocal.setSiteDefaultLocale(locale);
    }
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Region newRegion = _persistence.create(pk);

    newRegion.setMvccVersion(RandomTestUtil.nextLong());

    newRegion.setCountryId(RandomTestUtil.nextLong());

    newRegion.setRegionCode(RandomTestUtil.randomString());

    newRegion.setName(RandomTestUtil.randomString());

    newRegion.setActive(RandomTestUtil.randomBoolean());

    _persistence.update(newRegion);

    Region existingRegion = _persistence.findByPrimaryKey(newRegion.getPrimaryKey());

    Assert.assertEquals(existingRegion.getMvccVersion(), newRegion.getMvccVersion());
    Assert.assertEquals(existingRegion.getRegionId(), newRegion.getRegionId());
    Assert.assertEquals(existingRegion.getCountryId(), newRegion.getCountryId());
    Assert.assertEquals(existingRegion.getRegionCode(), newRegion.getRegionCode());
    Assert.assertEquals(existingRegion.getName(), newRegion.getName());
    Assert.assertEquals(existingRegion.getActive(), newRegion.getActive());
  }
  protected MDRRuleGroup addMDRRuleGroup() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MDRRuleGroup mdrRuleGroup = _persistence.create(pk);

    mdrRuleGroup.setUuid(RandomTestUtil.randomString());

    mdrRuleGroup.setGroupId(RandomTestUtil.nextLong());

    mdrRuleGroup.setCompanyId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserName(RandomTestUtil.randomString());

    mdrRuleGroup.setCreateDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setModifiedDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setName(RandomTestUtil.randomString());

    mdrRuleGroup.setDescription(RandomTestUtil.randomString());

    _persistence.update(mdrRuleGroup);

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

    ExpandoColumn newExpandoColumn = _persistence.create(pk);

    newExpandoColumn.setCompanyId(RandomTestUtil.nextLong());

    newExpandoColumn.setTableId(RandomTestUtil.nextLong());

    newExpandoColumn.setName(RandomTestUtil.randomString());

    newExpandoColumn.setType(RandomTestUtil.nextInt());

    newExpandoColumn.setDefaultData(RandomTestUtil.randomString());

    newExpandoColumn.setTypeSettings(RandomTestUtil.randomString());

    _expandoColumns.add(_persistence.update(newExpandoColumn));

    ExpandoColumn existingExpandoColumn =
        _persistence.findByPrimaryKey(newExpandoColumn.getPrimaryKey());

    Assert.assertEquals(existingExpandoColumn.getColumnId(), newExpandoColumn.getColumnId());
    Assert.assertEquals(existingExpandoColumn.getCompanyId(), newExpandoColumn.getCompanyId());
    Assert.assertEquals(existingExpandoColumn.getTableId(), newExpandoColumn.getTableId());
    Assert.assertEquals(existingExpandoColumn.getName(), newExpandoColumn.getName());
    Assert.assertEquals(existingExpandoColumn.getType(), newExpandoColumn.getType());
    Assert.assertEquals(existingExpandoColumn.getDefaultData(), newExpandoColumn.getDefaultData());
    Assert.assertEquals(
        existingExpandoColumn.getTypeSettings(), newExpandoColumn.getTypeSettings());
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    ResourceBlock newResourceBlock = _persistence.create(pk);

    newResourceBlock.setMvccVersion(RandomTestUtil.nextLong());

    newResourceBlock.setCompanyId(RandomTestUtil.nextLong());

    newResourceBlock.setGroupId(RandomTestUtil.nextLong());

    newResourceBlock.setName(RandomTestUtil.randomString());

    newResourceBlock.setPermissionsHash(RandomTestUtil.randomString());

    newResourceBlock.setReferenceCount(RandomTestUtil.nextLong());

    _resourceBlocks.add(_persistence.update(newResourceBlock));

    ResourceBlock existingResourceBlock =
        _persistence.findByPrimaryKey(newResourceBlock.getPrimaryKey());

    Assert.assertEquals(existingResourceBlock.getMvccVersion(), newResourceBlock.getMvccVersion());
    Assert.assertEquals(
        existingResourceBlock.getResourceBlockId(), newResourceBlock.getResourceBlockId());
    Assert.assertEquals(existingResourceBlock.getCompanyId(), newResourceBlock.getCompanyId());
    Assert.assertEquals(existingResourceBlock.getGroupId(), newResourceBlock.getGroupId());
    Assert.assertEquals(existingResourceBlock.getName(), newResourceBlock.getName());
    Assert.assertEquals(
        existingResourceBlock.getPermissionsHash(), newResourceBlock.getPermissionsHash());
    Assert.assertEquals(
        existingResourceBlock.getReferenceCount(), newResourceBlock.getReferenceCount());
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Portlet newPortlet = _persistence.create(pk);

    newPortlet.setMvccVersion(RandomTestUtil.nextLong());

    newPortlet.setCompanyId(RandomTestUtil.nextLong());

    newPortlet.setPortletId(RandomTestUtil.randomString());

    newPortlet.setRoles(RandomTestUtil.randomString());

    newPortlet.setActive(RandomTestUtil.randomBoolean());

    _persistence.update(newPortlet);

    Portlet existingPortlet = _persistence.findByPrimaryKey(newPortlet.getPrimaryKey());

    Assert.assertEquals(existingPortlet.getMvccVersion(), newPortlet.getMvccVersion());
    Assert.assertEquals(existingPortlet.getId(), newPortlet.getId());
    Assert.assertEquals(existingPortlet.getCompanyId(), newPortlet.getCompanyId());
    Assert.assertEquals(existingPortlet.getPortletId(), newPortlet.getPortletId());
    Assert.assertEquals(existingPortlet.getRoles(), newPortlet.getRoles());
    Assert.assertEquals(existingPortlet.getActive(), newPortlet.getActive());
  }
  @Test
  public void testAddSubfolder() throws Exception {
    BookmarksFolder folder =
        BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksTestUtil.addFolder(
        _group.getGroupId(), folder.getFolderId(), RandomTestUtil.randomString());
  }
Exemplo n.º 11
0
  protected void searchRecentEntries() throws Exception {
    long initialSearchGroupEntriesCount = searchGroupEntriesCount(group.getGroupId(), 0);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    BaseModel<?> parentBaseModel1 = getParentBaseModel(group, serviceContext);
    BaseModel<?> parentBaseModel2 = getParentBaseModel(group, serviceContext);

    String name = PrincipalThreadLocal.getName();

    try {
      User user1 = UserTestUtil.addUser(null, 0);

      PrincipalThreadLocal.setName(user1.getUserId());

      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel2, true, RandomTestUtil.randomString(), serviceContext);

      User user2 = UserTestUtil.addUser(null, 0);

      PrincipalThreadLocal.setName(user2.getUserId());

      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel2, true, RandomTestUtil.randomString(), serviceContext);
    } finally {
      PrincipalThreadLocal.setName(name);
    }

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 5, searchGroupEntriesCount(group.getGroupId(), 0));

    moveParentBaseModelToTrash((Long) parentBaseModel2.getPrimaryKeyObj());

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 3, searchGroupEntriesCount(group.getGroupId(), 0));

    TrashHandler parentTrashHandler =
        TrashHandlerRegistryUtil.getTrashHandler(getParentBaseModelClassName());

    parentTrashHandler.restoreTrashEntry(
        TestPropsValues.getUserId(), (Long) parentBaseModel2.getPrimaryKeyObj());

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 5, searchGroupEntriesCount(group.getGroupId(), 0));
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();
    importedGroup = GroupTestUtil.addGroup();

    layout = LayoutTestUtil.addLayout(group.getGroupId(), RandomTestUtil.randomString());

    // Delete and readd to ensure a different layout ID (not ID or UUID).
    // See LPS-32132.

    LayoutLocalServiceUtil.deleteLayout(layout, true, new ServiceContext());

    layout = LayoutTestUtil.addLayout(group.getGroupId(), RandomTestUtil.randomString());
  }
  @Override
  protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext)
      throws Exception {

    serviceContext = (ServiceContext) serviceContext.clone();

    serviceContext.setWorkflowAction(WorkflowConstants.STATUS_APPROVED);

    return WikiNodeLocalServiceUtil.addNode(
        TestPropsValues.getUserId(),
        RandomTestUtil.randomString(_NODE_NAME_MAX_LENGTH),
        RandomTestUtil.randomString(),
        serviceContext);
  }
  protected MBThread addMBThread() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBThread mbThread = _persistence.create(pk);

    mbThread.setUuid(RandomTestUtil.randomString());

    mbThread.setGroupId(RandomTestUtil.nextLong());

    mbThread.setCompanyId(RandomTestUtil.nextLong());

    mbThread.setUserId(RandomTestUtil.nextLong());

    mbThread.setUserName(RandomTestUtil.randomString());

    mbThread.setCreateDate(RandomTestUtil.nextDate());

    mbThread.setModifiedDate(RandomTestUtil.nextDate());

    mbThread.setCategoryId(RandomTestUtil.nextLong());

    mbThread.setRootMessageId(RandomTestUtil.nextLong());

    mbThread.setRootMessageUserId(RandomTestUtil.nextLong());

    mbThread.setMessageCount(RandomTestUtil.nextInt());

    mbThread.setViewCount(RandomTestUtil.nextInt());

    mbThread.setLastPostByUserId(RandomTestUtil.nextLong());

    mbThread.setLastPostDate(RandomTestUtil.nextDate());

    mbThread.setPriority(RandomTestUtil.nextDouble());

    mbThread.setQuestion(RandomTestUtil.randomBoolean());

    mbThread.setStatus(RandomTestUtil.nextInt());

    mbThread.setStatusByUserId(RandomTestUtil.nextLong());

    mbThread.setStatusByUserName(RandomTestUtil.randomString());

    mbThread.setStatusDate(RandomTestUtil.nextDate());

    _mbThreads.add(_persistence.update(mbThread));

    return mbThread;
  }
  protected void testRevertPage(boolean hasExpandoValues) throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    String originalContent = RandomTestUtil.randomString();

    WikiPage originalPage =
        WikiTestUtil.addPage(
            TestPropsValues.getUserId(),
            _node.getNodeId(),
            RandomTestUtil.randomString(),
            originalContent,
            true,
            serviceContext);

    if (hasExpandoValues) {
      addExpandoValueToPage(originalPage);
    }

    WikiPage updatedPage1 =
        WikiTestUtil.updatePage(
            originalPage,
            TestPropsValues.getUserId(),
            originalContent + "\nAdded second line.",
            serviceContext);

    Assert.assertNotEquals(originalContent, updatedPage1.getContent());

    WikiPage updatedPage2 =
        WikiTestUtil.updatePage(
            updatedPage1,
            TestPropsValues.getUserId(),
            updatedPage1.getContent() + "\nAdded third line.",
            serviceContext);

    Assert.assertNotEquals(originalContent, updatedPage2.getContent());

    WikiPage revertedPage =
        WikiPageLocalServiceUtil.revertPage(
            TestPropsValues.getUserId(),
            _node.getNodeId(),
            updatedPage2.getTitle(),
            originalPage.getVersion(),
            serviceContext);

    Assert.assertEquals(revertedPage.getContent(), originalContent);

    checkPopulatedServiceContext(serviceContext, revertedPage, hasExpandoValues);
  }
Exemplo n.º 16
0
  protected void searchBaseModelWithUpdate() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    SearchContext searchContext = SearchContextTestUtil.getSearchContext(group.getGroupId());

    BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext);

    searchContext.setKeywords(getSearchKeywords());

    int initialBaseModelsSearchCount =
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext);

    baseModel = addBaseModel(parentBaseModel, true, getSearchKeywords(), serviceContext);

    Assert.assertEquals(
        initialBaseModelsSearchCount + 1,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));

    String updatedKeywords = RandomTestUtil.randomString();

    baseModel = updateBaseModel(baseModel, updatedKeywords, serviceContext);

    Assert.assertEquals(
        initialBaseModelsSearchCount,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));

    searchContext.setKeywords(updatedKeywords);

    Assert.assertEquals(
        initialBaseModelsSearchCount + 1,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));
  }
  @Override
  protected BaseModel<?> getParentBaseModel(
      BaseModel<?> parentBaseModel, ServiceContext serviceContext) throws Exception {

    return JournalTestUtil.addFolder(
        (Long) parentBaseModel.getPrimaryKeyObj(), RandomTestUtil.randomString(), serviceContext);
  }
  @Test
  public void testSearchAndVerifyDocs() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    BookmarksFolder folder =
        BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksEntry entry = BookmarksTestUtil.addEntry(folder.getFolderId(), true, serviceContext);

    SearchContext searchContext =
        BookmarksTestUtil.getSearchContext(
            entry.getCompanyId(), entry.getGroupId(), entry.getFolderId(), "test");

    Indexer indexer = IndexerRegistryUtil.getIndexer(BookmarksEntry.class);

    Hits hits = indexer.search(searchContext);

    Assert.assertEquals(1, hits.getLength());

    List<Document> results = hits.toList();

    for (Document doc : results) {
      Assert.assertEquals(entry.getCompanyId(), GetterUtil.getLong(doc.get(Field.COMPANY_ID)));
      Assert.assertEquals(BookmarksEntry.class.getName(), doc.get(Field.ENTRY_CLASS_NAME));
      Assert.assertEquals(entry.getEntryId(), GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)));
      AssertUtils.assertEqualsIgnoreCase(entry.getName(), doc.get(Field.TITLE));
      Assert.assertEquals(entry.getUrl(), doc.get(Field.URL));
    }
  }
Exemplo n.º 19
0
  protected void searchComments() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    SearchContext searchContext = SearchContextTestUtil.getSearchContext(group.getGroupId());

    searchContext.setIncludeDiscussions(true);

    BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext);

    int initialBaseModelsSearchCount =
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext);

    baseModel = addBaseModel(parentBaseModel, true, RandomTestUtil.randomString(), serviceContext);

    Assert.assertEquals(
        initialBaseModelsSearchCount + 1,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));

    addComment(baseModel, getSearchKeywords(), serviceContext);

    Assert.assertEquals(
        initialBaseModelsSearchCount + 2,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));

    moveBaseModelToTrash((Long) baseModel.getPrimaryKeyObj());

    Assert.assertEquals(
        initialBaseModelsSearchCount,
        searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext));
  }
  @Test
  public void testSearchAndDeleteFolderAndSearch() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    BookmarksFolder folder =
        BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksEntry entry = BookmarksTestUtil.addEntry(folder.getFolderId(), true, serviceContext);

    long companyId = entry.getCompanyId();
    long groupId = entry.getFolder().getGroupId();
    long folderId = entry.getFolderId();
    String keywords = "test";

    SearchContext searchContext =
        BookmarksTestUtil.getSearchContext(companyId, groupId, folderId, keywords);

    Indexer indexer = IndexerRegistryUtil.getIndexer(BookmarksEntry.class);

    Hits hits = indexer.search(searchContext);

    Assert.assertEquals(1, hits.getLength());

    BookmarksFolderLocalServiceUtil.deleteFolder(folderId);

    hits = indexer.search(searchContext);

    Query query = hits.getQuery();

    Assert.assertEquals(query.toString(), 0, hits.getLength());
  }
  @Test
  public void testDeleteFolder() throws Exception {
    BookmarksFolder folder =
        BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksFolderServiceUtil.deleteFolder(folder.getFolderId());
  }
  @Test
  public void testChangeChildPageNode() throws Exception {
    WikiNode destinationNode = WikiTestUtil.addNode(_group.getGroupId());

    WikiTestUtil.addPage(
        TestPropsValues.getUserId(), _group.getGroupId(), _node.getNodeId(), "ParentPage", true);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    WikiTestUtil.addPage(
        TestPropsValues.getUserId(),
        _node.getNodeId(),
        "ChildPage",
        RandomTestUtil.randomString(),
        "ParentPage",
        true,
        serviceContext);

    WikiPageLocalServiceUtil.changeNode(
        TestPropsValues.getUserId(),
        _node.getNodeId(),
        "ChildPage",
        destinationNode.getNodeId(),
        serviceContext);

    WikiPage parentPage = WikiPageLocalServiceUtil.getPage(_node.getNodeId(), "ParentPage");
    WikiPage childPage = WikiPageLocalServiceUtil.getPage(destinationNode.getNodeId(), "ChildPage");

    Assert.assertEquals(_node.getNodeId(), parentPage.getNodeId());
    Assert.assertEquals(destinationNode.getNodeId(), childPage.getNodeId());
    Assert.assertTrue(Validator.isNull(childPage.getParentTitle()));
  }
  protected SocialActivitySet addSocialActivitySet() throws Exception {
    long pk = RandomTestUtil.nextLong();

    SocialActivitySet socialActivitySet = _persistence.create(pk);

    socialActivitySet.setGroupId(RandomTestUtil.nextLong());

    socialActivitySet.setCompanyId(RandomTestUtil.nextLong());

    socialActivitySet.setUserId(RandomTestUtil.nextLong());

    socialActivitySet.setCreateDate(RandomTestUtil.nextLong());

    socialActivitySet.setModifiedDate(RandomTestUtil.nextLong());

    socialActivitySet.setClassNameId(RandomTestUtil.nextLong());

    socialActivitySet.setClassPK(RandomTestUtil.nextLong());

    socialActivitySet.setType(RandomTestUtil.nextInt());

    socialActivitySet.setExtraData(RandomTestUtil.randomString());

    socialActivitySet.setActivityCount(RandomTestUtil.nextInt());

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

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

    TrashVersion newTrashVersion = _persistence.create(pk);

    newTrashVersion.setEntryId(RandomTestUtil.nextLong());

    newTrashVersion.setClassNameId(RandomTestUtil.nextLong());

    newTrashVersion.setClassPK(RandomTestUtil.nextLong());

    newTrashVersion.setTypeSettings(RandomTestUtil.randomString());

    newTrashVersion.setStatus(RandomTestUtil.nextInt());

    _trashVersions.add(_persistence.update(newTrashVersion));

    TrashVersion existingTrashVersion =
        _persistence.findByPrimaryKey(newTrashVersion.getPrimaryKey());

    Assert.assertEquals(existingTrashVersion.getVersionId(), newTrashVersion.getVersionId());
    Assert.assertEquals(existingTrashVersion.getEntryId(), newTrashVersion.getEntryId());
    Assert.assertEquals(existingTrashVersion.getClassNameId(), newTrashVersion.getClassNameId());
    Assert.assertEquals(existingTrashVersion.getClassPK(), newTrashVersion.getClassPK());
    Assert.assertEquals(existingTrashVersion.getTypeSettings(), newTrashVersion.getTypeSettings());
    Assert.assertEquals(existingTrashVersion.getStatus(), newTrashVersion.getStatus());
  }
  @Test
  public void testJournalFolderTreePathWithJournalFolderInTrash() throws Exception {

    JournalFolder parentFolder =
        JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    JournalFolder folder =
        JournalTestUtil.addFolder(
            _group.getGroupId(), parentFolder.getFolderId(), RandomTestUtil.randomString());

    JournalFolderLocalServiceUtil.moveFolderToTrash(
        TestPropsValues.getUserId(), folder.getFolderId());

    JournalFolderLocalServiceUtil.deleteFolder(parentFolder.getFolderId(), false);

    doVerify();
  }
  @Override
  protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext)
      throws Exception {

    return JournalTestUtil.addFolder(
        JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
        RandomTestUtil.randomString(),
        serviceContext);
  }
  @Override
  protected StagedModel addStagedModel(
      Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception {

    List<StagedModel> dependentStagedModels =
        dependentStagedModelsMap.get(WikiNode.class.getSimpleName());

    WikiNode node = (WikiNode) dependentStagedModels.get(0);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    WikiPage page =
        WikiTestUtil.addPage(
            TestPropsValues.getUserId(),
            node.getNodeId(),
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            true,
            serviceContext);

    WikiTestUtil.addWikiAttachment(
        TestPropsValues.getUserId(), node.getNodeId(), page.getTitle(), WikiAttachmentsTest.class);

    List<FileEntry> attachmentsFileEntries = page.getAttachmentsFileEntries();

    FileEntry fileEntry = attachmentsFileEntries.get(0);

    Folder folder = fileEntry.getFolder();

    while (folder != null) {
      addDependentStagedModel(dependentStagedModelsMap, DLFolder.class, folder);

      folder = folder.getParentFolder();
    }

    addDependentStagedModel(
        dependentStagedModelsMap, DLFileEntry.class, attachmentsFileEntries.get(0));

    Repository repository = RepositoryUtil.fetchByPrimaryKey(fileEntry.getRepositoryId());

    addDependentStagedModel(dependentStagedModelsMap, Repository.class, repository);

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

    MDRRuleGroup newMDRRuleGroup = _persistence.create(pk);

    newMDRRuleGroup.setUuid(RandomTestUtil.randomString());

    newMDRRuleGroup.setGroupId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setCompanyId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setUserId(RandomTestUtil.nextLong());

    newMDRRuleGroup.setUserName(RandomTestUtil.randomString());

    newMDRRuleGroup.setCreateDate(RandomTestUtil.nextDate());

    newMDRRuleGroup.setModifiedDate(RandomTestUtil.nextDate());

    newMDRRuleGroup.setName(RandomTestUtil.randomString());

    newMDRRuleGroup.setDescription(RandomTestUtil.randomString());

    _persistence.update(newMDRRuleGroup);

    MDRRuleGroup existingMDRRuleGroup =
        _persistence.findByPrimaryKey(newMDRRuleGroup.getPrimaryKey());

    Assert.assertEquals(existingMDRRuleGroup.getUuid(), newMDRRuleGroup.getUuid());
    Assert.assertEquals(existingMDRRuleGroup.getRuleGroupId(), newMDRRuleGroup.getRuleGroupId());
    Assert.assertEquals(existingMDRRuleGroup.getGroupId(), newMDRRuleGroup.getGroupId());
    Assert.assertEquals(existingMDRRuleGroup.getCompanyId(), newMDRRuleGroup.getCompanyId());
    Assert.assertEquals(existingMDRRuleGroup.getUserId(), newMDRRuleGroup.getUserId());
    Assert.assertEquals(existingMDRRuleGroup.getUserName(), newMDRRuleGroup.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingMDRRuleGroup.getCreateDate()),
        Time.getShortTimestamp(newMDRRuleGroup.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingMDRRuleGroup.getModifiedDate()),
        Time.getShortTimestamp(newMDRRuleGroup.getModifiedDate()));
    Assert.assertEquals(existingMDRRuleGroup.getName(), newMDRRuleGroup.getName());
    Assert.assertEquals(existingMDRRuleGroup.getDescription(), newMDRRuleGroup.getDescription());
  }
  @Test
  public void testJournalArticleTreePathWithParentJournalFolderInTrash() throws Exception {

    JournalFolder grandparentFolder =
        JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    JournalFolder parentFolder =
        JournalTestUtil.addFolder(
            _group.getGroupId(), grandparentFolder.getFolderId(), RandomTestUtil.randomString());

    JournalTestUtil.addArticle(_group.getGroupId(), parentFolder.getFolderId(), "title", "content");

    JournalFolderLocalServiceUtil.moveFolderToTrash(
        TestPropsValues.getUserId(), parentFolder.getFolderId());

    JournalFolderLocalServiceUtil.deleteFolder(grandparentFolder.getFolderId(), false);

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

    JournalArticleImage newJournalArticleImage = _persistence.create(pk);

    newJournalArticleImage.setGroupId(RandomTestUtil.nextLong());

    newJournalArticleImage.setArticleId(RandomTestUtil.randomString());

    newJournalArticleImage.setVersion(RandomTestUtil.nextDouble());

    newJournalArticleImage.setElInstanceId(RandomTestUtil.randomString());

    newJournalArticleImage.setElName(RandomTestUtil.randomString());

    newJournalArticleImage.setLanguageId(RandomTestUtil.randomString());

    newJournalArticleImage.setTempImage(RandomTestUtil.randomBoolean());

    _journalArticleImages.add(_persistence.update(newJournalArticleImage));

    JournalArticleImage existingJournalArticleImage =
        _persistence.findByPrimaryKey(newJournalArticleImage.getPrimaryKey());

    Assert.assertEquals(
        existingJournalArticleImage.getArticleImageId(),
        newJournalArticleImage.getArticleImageId());
    Assert.assertEquals(
        existingJournalArticleImage.getGroupId(), newJournalArticleImage.getGroupId());
    Assert.assertEquals(
        existingJournalArticleImage.getArticleId(), newJournalArticleImage.getArticleId());
    AssertUtils.assertEquals(
        existingJournalArticleImage.getVersion(), newJournalArticleImage.getVersion());
    Assert.assertEquals(
        existingJournalArticleImage.getElInstanceId(), newJournalArticleImage.getElInstanceId());
    Assert.assertEquals(
        existingJournalArticleImage.getElName(), newJournalArticleImage.getElName());
    Assert.assertEquals(
        existingJournalArticleImage.getLanguageId(), newJournalArticleImage.getLanguageId());
    Assert.assertEquals(
        existingJournalArticleImage.getTempImage(), newJournalArticleImage.getTempImage());
  }