@Test public void testSimpleEscapedCharacter() { WikiPageNode wikiPageNode = getWikiPageNode("escape-1.creole"); Assert.assertNotNull(wikiPageNode); Assert.assertEquals(1, wikiPageNode.getChildASTNodesCount()); ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0); Assert.assertEquals(2, paragraphNode.getChildASTNodesCount()); LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0); Assert.assertEquals(2, lineNode.getChildASTNodesCount()); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) lineNode.getChildASTNode(0); ScapedNode scapedNode = (ScapedNode) unformattedTextNode.getChildASTNode(0); Assert.assertEquals("E", scapedNode.getContent()); CollectionNode collectionNode = (CollectionNode) lineNode.getChildASTNode(1); unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("SCAPED1", unformattedTextNode.getContent()); }
@Test public void testParseSimpleTextWithBoldAndItalics() { WikiPageNode wikiPageNode = getWikiPageNode("text-5.creole"); Assert.assertNotNull(wikiPageNode); Assert.assertEquals(1, wikiPageNode.getChildASTNodesCount()); ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0); Assert.assertEquals(1, paragraphNode.getChildASTNodesCount()); LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0); Assert.assertEquals(4, lineNode.getChildASTNodesCount()); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) lineNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0); Assert.assertEquals("Text with some content in ", unformattedTextNode.getContent()); BoldTextNode boldTextNode = (BoldTextNode) lineNode.getChildASTNode(1); Assert.assertEquals(1, boldTextNode.getChildASTNodesCount()); FormattedTextNode formattedTextNode = (FormattedTextNode) boldTextNode.getChildASTNode(0); CollectionNode collectionNode = (CollectionNode) formattedTextNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("bold", unformattedTextNode.getContent()); }
@Test public void testParseSimpleTextWithForcedEndline() { WikiPageNode wikiPageNode = getWikiPageNode("text-7.creole"); Assert.assertNotNull(wikiPageNode); Assert.assertEquals(1, wikiPageNode.getChildASTNodesCount()); ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0); Assert.assertEquals(1, paragraphNode.getChildASTNodesCount()); LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0); Assert.assertEquals(3, lineNode.getChildASTNodesCount()); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) lineNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0); Assert.assertEquals("Text with ", unformattedTextNode.getContent()); CollectionNode collectionNode = (CollectionNode) lineNode.getChildASTNode(1); Assert.assertEquals(1, collectionNode.size()); Assert.assertTrue(collectionNode.get(0) instanceof ForcedEndOfLineNode); collectionNode = (CollectionNode) lineNode.getChildASTNode(2); unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("forced line break", unformattedTextNode.getContent()); }
@Test public void testParseSimpleTextBoldAndItalics() { WikiPageNode wikiPageNode = getWikiPageNode("text-6.creole"); Assert.assertNotNull(wikiPageNode); Assert.assertEquals(1, wikiPageNode.getChildASTNodesCount()); ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0); Assert.assertEquals(1, paragraphNode.getChildASTNodesCount()); LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0); Assert.assertEquals(2, lineNode.getChildASTNodesCount()); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) lineNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0); Assert.assertEquals("Text ", unformattedTextNode.getContent()); BoldTextNode boldTextNode = (BoldTextNode) lineNode.getChildASTNode(1); Assert.assertEquals(1, boldTextNode.getChildASTNodesCount()); ItalicTextNode italicTextNode = (ItalicTextNode) boldTextNode.getChildASTNode(0); CollectionNode collectionNode = (CollectionNode) italicTextNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("ItalicAndBold", unformattedTextNode.getContent()); }