@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()); }
@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()); }
@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()); } }
@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()); } }
@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()); } }
@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()); }