protected void testRestorePageFromTrash(boolean hasExpandoValues) throws Exception { WikiPage page = WikiTestUtil.addPage(_group.getGroupId(), _node.getNodeId(), true); if (hasExpandoValues) { addExpandoValueToPage(page); } page = WikiPageLocalServiceUtil.movePageToTrash( TestPropsValues.getUserId(), _node.getNodeId(), page.getTitle()); WikiPageLocalServiceUtil.restorePageFromTrash(TestPropsValues.getUserId(), page); WikiPage restoredPage = WikiPageLocalServiceUtil.getPage(page.getResourcePrimKey()); Assert.assertNotNull(restoredPage); if (hasExpandoValues) { ExpandoBridge expandoBridge = page.getExpandoBridge(); ExpandoBridge restoredExpandoBridge = restoredPage.getExpandoBridge(); AssertUtils.assertEquals( restoredExpandoBridge.getAttributes(), expandoBridge.getAttributes()); } }
protected void checkPopulatedServiceContext( ServiceContext serviceContext, WikiPage page, boolean hasExpandoValues) throws Exception { long[] assetCategoryIds = AssetCategoryLocalServiceUtil.getCategoryIds( WikiPage.class.getName(), page.getResourcePrimKey()); Assert.assertArrayEquals(serviceContext.getAssetCategoryIds(), assetCategoryIds); AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(WikiPage.class.getName(), page.getResourcePrimKey()); List<AssetLink> assetLinks = AssetLinkLocalServiceUtil.getLinks(assetEntry.getEntryId()); long[] assetLinkEntryIds = ListUtil.toLongArray(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR); Assert.assertArrayEquals(serviceContext.getAssetLinkEntryIds(), assetLinkEntryIds); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(WikiPage.class.getName(), page.getResourcePrimKey()); Assert.assertArrayEquals(serviceContext.getAssetTagNames(), assetTagNames); if (hasExpandoValues) { ExpandoBridge expandoBridge = page.getExpandoBridge(); AssertUtils.assertEquals( expandoBridge.getAttributes(), serviceContext.getExpandoBridgeAttributes()); } }
protected void addExpandoValueToPage(WikiPage page) throws Exception { ExpandoValue value = ExpandoTestUtil.addValue( PortalUtil.getClassNameId(WikiPage.class), page.getPrimaryKey(), RandomTestUtil.randomString()); ExpandoBridge expandoBridge = page.getExpandoBridge(); ExpandoColumn column = value.getColumn(); expandoBridge.addAttribute(column.getName(), ExpandoColumnConstants.STRING, value.getString()); }