@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()); }
@Test public void testParseCorrectlyItalicContentInListItems() { UnorderedListNode unorderedListNode = (UnorderedListNode) parseBaseListNode("list-5.creole"); Assert.assertEquals(1, unorderedListNode.getChildASTNodesCount()); UnorderedListItemNode unorderedListItemNode = (UnorderedListItemNode) unorderedListNode.getChildASTNode(0); Assert.assertNotNull(unorderedListItemNode); Assert.assertEquals(2, unorderedListItemNode.getChildASTNodesCount()); FormattedTextNode formattedTextNode = (FormattedTextNode) unorderedListItemNode.getChildASTNode(1); ItalicTextNode italicTextNode = (ItalicTextNode) formattedTextNode.getChildASTNode(0); CollectionNode collectionNode = (CollectionNode) italicTextNode.getChildASTNode(0); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("abcdefg", unformattedTextNode.getContent()); }
@Test public void testParseSimpleTextWithItalics() { WikiPageNode wikiPageNode = getWikiPageNode("text-3.creole"); Assert.assertNotNull(wikiPageNode); List<ASTNode> astNodes = wikiPageNode.getChildASTNodes(); Assert.assertEquals(1, astNodes.size()); ParagraphNode paragraphNode = (ParagraphNode) astNodes.get(0); astNodes = paragraphNode.getChildASTNodes(); Assert.assertEquals(1, astNodes.size()); 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 with some content in ", unformattedTextNode.getContent()); ItalicTextNode italicTextNode = (ItalicTextNode) lineNode.getChildASTNode(1); FormattedTextNode formattedTextNode = (FormattedTextNode) italicTextNode.getChildASTNode(0); CollectionNode collectionNode = (CollectionNode) formattedTextNode.getChildASTNode(0); unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("italic", unformattedTextNode.getContent()); }