コード例 #1
0
  @Test
  public void testMoveParentPageToTrash() throws Exception {
    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(group.getGroupId(), _node.getNodeId(), false);

    WikiPage parentPage = pages[0];
    WikiPage childPage = pages[1];

    Assert.assertTrue(parentPage.isInTrashExplicitly());
    Assert.assertTrue(childPage.isInTrashImplicitly());
    Assert.assertEquals(childPage.getParentTitle(), parentPage.getTitle());
  }
コード例 #2
0
  @Test
  public void testRestoreExplicitlyTrashedParentPageFromTrash() throws Exception {

    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(group.getGroupId(), _node.getNodeId(), false);

    WikiPage parentPage = pages[0];
    WikiPage childPage = pages[1];

    restoreTrashEntry(parentPage);

    parentPage = WikiPageLocalServiceUtil.getPageByPageId(parentPage.getPageId());
    childPage = WikiPageLocalServiceUtil.getPageByPageId(childPage.getPageId());

    Assert.assertFalse(parentPage.isInTrash());
    Assert.assertFalse(childPage.isInTrash());
    Assert.assertEquals(childPage.getParentTitle(), parentPage.getTitle());
  }
コード例 #3
0
  @Test(expected = NoSuchPageResourceException.class)
  public void testDeleteTrashedParentPageWithImplicitTrashedChildPage() throws Exception {

    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(_group.getGroupId(), _node.getNodeId(), false);

    WikiPage parentPage = pages[0];
    WikiPage childPage = pages[1];

    WikiPageLocalServiceUtil.deletePage(parentPage);

    try {
      WikiPageLocalServiceUtil.getPage(parentPage.getResourcePrimKey());

      Assert.fail();
    } catch (NoSuchPageResourceException nspre) {
      WikiPageLocalServiceUtil.getPage(childPage.getResourcePrimKey());
    }
  }
コード例 #4
0
  @Test
  public void testDeleteTrashedParentPageWithExplicitTrashedChildPage() throws Exception {

    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(_group.getGroupId(), _node.getNodeId(), true);

    WikiPage parentPage = pages[0];
    WikiPage childPage = pages[1];

    WikiPageLocalServiceUtil.deletePage(parentPage);

    try {
      WikiPageLocalServiceUtil.getPage(parentPage.getResourcePrimKey());

      Assert.fail();
    } catch (NoSuchPageResourceException nspre) {
      childPage = WikiPageLocalServiceUtil.getPageByPageId(childPage.getPageId());

      Assert.assertNull(childPage.fetchParentPage());
    }
  }
コード例 #5
0
  @Test
  public void testDeleteTrashedPageWithRestoredChildPage() throws Exception {
    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(_group.getGroupId(), _node.getNodeId(), true);

    WikiPage parentPage = pages[0];
    WikiPage childPage = pages[1];

    WikiPageLocalServiceUtil.restorePageFromTrash(TestPropsValues.getUserId(), childPage);

    WikiPageLocalServiceUtil.deletePage(parentPage);

    try {
      WikiPageLocalServiceUtil.getPage(parentPage.getResourcePrimKey());

      Assert.fail();
    } catch (NoSuchPageResourceException nspre) {
      childPage = WikiPageLocalServiceUtil.getPage(childPage.getResourcePrimKey());

      Assert.assertNull(childPage.fetchParentPage());
      Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, childPage.getStatus());
    }
  }
コード例 #6
0
  @Test
  public void testRestorePageWithParentPageInTrash() throws Exception {
    WikiPage[] pages =
        WikiTestUtil.addTrashedPageWithChildPage(group.getGroupId(), _node.getNodeId(), false);

    WikiPage childPage = pages[1];

    WikiPage newParentPage = WikiTestUtil.addPage(group.getGroupId(), _node.getNodeId(), true);

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(getBaseModelClassName());

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

    trashHandler.moveEntry(
        TestPropsValues.getUserId(),
        childPage.getResourcePrimKey(),
        newParentPage.getResourcePrimKey(),
        serviceContext);

    childPage = WikiPageLocalServiceUtil.getPage(childPage.getResourcePrimKey());

    Assert.assertTrue(childPage.isApproved());
    Assert.assertEquals(newParentPage.getTitle(), childPage.getParentTitle());
  }