@Test
  public void testRestoreRedirectPageWithParentPageFromTrash() throws Exception {

    int initialBaseModelsCount = getNotInTrashBaseModelsCount(_node);
    int initialTrashEntriesCount = getTrashEntriesCount(group.getGroupId());

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

    WikiPage parentPage = pages[0];
    WikiPage redirectPage = pages[1];
    WikiPage childPage = pages[2];
    WikiPage grandchildPage = pages[3];

    moveBaseModelToTrash(redirectPage.getPrimaryKey());

    restoreTrashEntry(redirectPage);

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

    Assert.assertFalse(parentPage.isInTrash());
    Assert.assertFalse(redirectPage.isInTrashExplicitly());
    Assert.assertEquals(parentPage.getTitle(), redirectPage.getRedirectTitle());
    Assert.assertFalse(childPage.isInTrash());
    Assert.assertEquals(parentPage.getTitle(), childPage.getParentTitle());
    Assert.assertFalse(grandchildPage.isInTrash());
    Assert.assertEquals(childPage.getTitle(), grandchildPage.getParentTitle());
    Assert.assertEquals(initialBaseModelsCount + 4, getNotInTrashBaseModelsCount(_node));
    Assert.assertEquals(initialTrashEntriesCount, getTrashEntriesCount(group.getGroupId()));
  }
  @Test
  public void testRestoreExplicitlyTrashedParentPageWithRedirectPageFromTrash() throws Exception {

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

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

    restoreTrashEntry(parentPage);

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

    Assert.assertFalse(parentPage.isInTrash());
    Assert.assertFalse(childPage.isInTrash());
    Assert.assertEquals(childPage.getParentTitle(), parentPage.getTitle());
    Assert.assertTrue(redirectPage.isInTrashExplicitly());
    Assert.assertEquals(redirectPage.getRedirectTitle(), parentPage.getTitle());

    restoreTrashEntry(redirectPage);
  }
  @Test
  public void testRestoreExplicitlyTrashedParentPageWithChildPageAndgrandchildPageFromTrash()
      throws Exception {

    int initialBaseModelsCount = getNotInTrashBaseModelsCount(_node);
    int initialTrashEntriesCount = getTrashEntriesCount(group.getGroupId());

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

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

    restoreTrashEntry(parentPage);

    parentPage = (WikiPage) getBaseModel(parentPage.getPrimaryKey());
    childPage = (WikiPage) getBaseModel(childPage.getPrimaryKey());
    grandchildPage = (WikiPage) getBaseModel(grandchildPage.getPrimaryKey());

    Assert.assertFalse(parentPage.isInTrash());
    Assert.assertFalse(childPage.isInTrash());
    Assert.assertEquals(parentPage.getTitle(), childPage.getParentTitle());
    Assert.assertFalse(grandchildPage.isInTrash());
    Assert.assertEquals(childPage.getTitle(), grandchildPage.getParentTitle());
    Assert.assertEquals(initialBaseModelsCount + 3, getNotInTrashBaseModelsCount(_node));
    Assert.assertEquals(initialTrashEntriesCount, getTrashEntriesCount(group.getGroupId()));
  }
  @Test
  public void testMoveInitialParentPageToTrash() throws Exception {
    int initialBaseModelsCount = getNotInTrashBaseModelsCount(_node);
    int initialTrashEntriesCount = getTrashEntriesCount(group.getGroupId());

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

    WikiPage page = pages[0];
    WikiPage finalParentPage = pages[1];
    WikiPage initialParentPage = pages[2];

    WikiPageLocalServiceUtil.movePageToTrash(TestPropsValues.getUserId(), initialParentPage);

    page = WikiPageLocalServiceUtil.getPageByPageId(page.getPageId());
    finalParentPage = WikiPageLocalServiceUtil.getPageByPageId(finalParentPage.getPageId());
    initialParentPage = WikiPageLocalServiceUtil.getPageByPageId(initialParentPage.getPageId());

    Assert.assertFalse(page.isInTrash());
    Assert.assertFalse(finalParentPage.isInTrash());
    Assert.assertTrue(initialParentPage.isInTrashExplicitly());
    Assert.assertEquals(finalParentPage.getTitle(), page.getParentTitle());
    Assert.assertEquals(initialBaseModelsCount + 2, getNotInTrashBaseModelsCount(_node));
    Assert.assertEquals(initialTrashEntriesCount + 1, getTrashEntriesCount(group.getGroupId()));
    Assert.assertEquals(page.getParentTitle(), finalParentPage.getTitle());
  }
  public boolean isInTrash(long classPK) throws PortalException, SystemException {

    WikiPage page = WikiPageLocalServiceUtil.getPage(classPK);

    if (page.isInTrash() || page.isInTrashFolder()) {
      return true;
    }

    return false;
  }
  @Test
  public void testMoveExplicitlyChildPageWithChildPageToTrash() throws Exception {

    int initialBaseModelsCount = getNotInTrashBaseModelsCount(_node);
    int initialTrashEntriesCount = getTrashEntriesCount(group.getGroupId());

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

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

    Assert.assertFalse(parentPage.isInTrash());
    Assert.assertTrue(childPage.isInTrashExplicitly());
    Assert.assertTrue(grandchildPage.isInTrashImplicitly());
    Assert.assertEquals(childPage.getTitle(), grandchildPage.getParentTitle());
    Assert.assertEquals(initialBaseModelsCount + 1, getNotInTrashBaseModelsCount(_node));
    Assert.assertEquals(initialTrashEntriesCount + 1, getTrashEntriesCount(group.getGroupId()));
  }