@Test public void testParseCorrectlyNestedLevels() { UnorderedListNode unorderedListNode = (UnorderedListNode) parseBaseListNode("list-4.creole"); Assert.assertEquals(7, unorderedListNode.getChildASTNodesCount()); int level1Count = 0; int level2Count = 0; for (ASTNode astNode : unorderedListNode.getChildASTNodes()) { UnorderedListItemNode unorderedListItemNode = (UnorderedListItemNode) astNode; int currentLevel = unorderedListItemNode.getLevel(); if (currentLevel == 1) { level1Count += currentLevel; } else if (currentLevel == 2) { level2Count += currentLevel; } else { Assert.fail("Parsed has not been achieved correctly"); } } Assert.assertEquals(level1Count, 3 * 1); Assert.assertEquals(level2Count, 4 * 2); }
@Test public void testParseCorrectlyBoldContentInListItems() { UnorderedListNode unorderedListNode = (UnorderedListNode) parseBaseListNode("list-6.creole"); Assert.assertEquals(1, unorderedListNode.getChildASTNodesCount()); UnorderedListItemNode unorderedListItemNode = (UnorderedListItemNode) unorderedListNode.getChildASTNode(0); Assert.assertNotNull(unorderedListItemNode); FormattedTextNode formattedTextNode = (FormattedTextNode) unorderedListItemNode.getChildASTNode(1); BoldTextNode boldTextNode = (BoldTextNode) formattedTextNode.getChildASTNode(0); CollectionNode collectionNode = (CollectionNode) boldTextNode.getChildASTNode(0); UnformattedTextNode unformattedTextNode = (UnformattedTextNode) collectionNode.get(0); Assert.assertEquals("abcdefg", unformattedTextNode.getContent()); }
public void visit(UnorderedListItemNode unorderedListItemNode) { traverse(unorderedListItemNode.getChildASTNodes(), "<li>", "</li>"); }