@Test public void testChangeRedirectPageNode() throws Exception { WikiNode destinationNode = WikiTestUtil.addNode(_group.getGroupId()); WikiTestUtil.addPage( TestPropsValues.getUserId(), _group.getGroupId(), _node.getNodeId(), "InitialTitlePage", true); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); WikiPageLocalServiceUtil.renamePage( TestPropsValues.getUserId(), _node.getNodeId(), "InitialTitlePage", "RenamedPage", serviceContext); try { WikiPageLocalServiceUtil.changeNode( TestPropsValues.getUserId(), _node.getNodeId(), "InitialTitlePage", destinationNode.getNodeId(), serviceContext); Assert.fail(); } catch (NodeChangeException nce) { Assert.assertEquals("InitialTitlePage", nce.getPageTitle()); Assert.assertEquals(_node.getName(), nce.getNodeName()); Assert.assertEquals(NodeChangeException.REDIRECT_PAGE, nce.getType()); } }
@Test public void testChangePageNodeWithChildPageNameDuplication() 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(), "DuplicatedTitlePage", RandomTestUtil.randomString(), "ParentPage", true, serviceContext); WikiTestUtil.addPage( TestPropsValues.getUserId(), _group.getGroupId(), destinationNode.getNodeId(), "DuplicatedTitlePage", true); try { WikiPageLocalServiceUtil.changeNode( TestPropsValues.getUserId(), _node.getNodeId(), "ParentPage", destinationNode.getNodeId(), serviceContext); Assert.fail(); } catch (NodeChangeException nce) { Assert.assertEquals("DuplicatedTitlePage", nce.getPageTitle()); Assert.assertEquals(destinationNode.getName(), nce.getNodeName()); Assert.assertEquals(NodeChangeException.DUPLICATE_PAGE, nce.getType()); } }