@Test
  public void testParseTableMultipleRowsAndCOlumns() {
    WikiPageNode wikiPageNode = getWikiPageNode("table-2.creole");

    Assert.assertNotNull(wikiPageNode);

    TableNode tableNode = (TableNode) wikiPageNode.getChildASTNode(0);

    Assert.assertNotNull(tableNode);
    Assert.assertEquals(4, tableNode.getChildASTNodesCount());

    CollectionNode collectionNode = (CollectionNode) tableNode.getChildASTNode(0);

    Assert.assertEquals(4, collectionNode.size());

    for (int i = 0; i < 4; ++i) {
      TableHeaderNode tableHeaderNode = (TableHeaderNode) collectionNode.get(i);

      Assert.assertNotNull(tableHeaderNode);

      UnformattedTextNode unformattedTextNode =
          (UnformattedTextNode) tableHeaderNode.getChildASTNode(0);

      Assert.assertNotNull(unformattedTextNode);
      Assert.assertEquals(1, unformattedTextNode.getChildASTNodesCount());

      unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0);

      Assert.assertEquals("H" + (i + 1), unformattedTextNode.getContent());
    }

    int count = 1;

    for (int row = 1; row < 4; ++row) {
      collectionNode = (CollectionNode) tableNode.getChildASTNode(row);

      Assert.assertEquals(4, collectionNode.size());

      for (int column = 0; column < 4; ++column) {
        TableDataNode tableDataNode = (TableDataNode) collectionNode.get(column);

        Assert.assertNotNull(tableDataNode);

        UnformattedTextNode unformattedTextNode =
            (UnformattedTextNode) tableDataNode.getChildASTNode(0);

        Assert.assertNotNull(unformattedTextNode);
        Assert.assertEquals(1, unformattedTextNode.getChildASTNodesCount());

        unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0);

        Assert.assertEquals("C" + count++, unformattedTextNode.getContent());
      }
    }
  }
  @Test
  public void testParseTableOneRowOneColumn() {
    WikiPageNode wikiPageNode = getWikiPageNode("table-1.creole");

    Assert.assertNotNull(wikiPageNode);

    TableNode tableNode = (TableNode) wikiPageNode.getChildASTNode(0);

    Assert.assertNotNull(tableNode);
    Assert.assertEquals(2, tableNode.getChildASTNodesCount());

    CollectionNode collectionNode = (CollectionNode) tableNode.getChildASTNode(0);

    Assert.assertEquals(1, collectionNode.size());

    TableHeaderNode tableHeaderNode = (TableHeaderNode) collectionNode.get(0);

    Assert.assertNotNull(tableHeaderNode);

    UnformattedTextNode unformattedTextNode =
        (UnformattedTextNode) tableHeaderNode.getChildASTNode(0);

    Assert.assertNotNull(unformattedTextNode);
    Assert.assertEquals(1, unformattedTextNode.getChildASTNodesCount());

    unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0);

    Assert.assertEquals("H1", unformattedTextNode.getContent());

    List<ASTNode> astNodes = tableNode.getChildASTNodes();

    collectionNode = (CollectionNode) astNodes.get(1);

    Assert.assertEquals(1, collectionNode.size());

    TableDataNode tableDataNode = (TableDataNode) collectionNode.get(0);

    Assert.assertNotNull(tableDataNode);

    unformattedTextNode = (UnformattedTextNode) tableDataNode.getChildASTNode(0);

    Assert.assertNotNull(unformattedTextNode);
    Assert.assertEquals(1, unformattedTextNode.getChildASTNodesCount());

    unformattedTextNode = (UnformattedTextNode) unformattedTextNode.getChildASTNode(0);

    Assert.assertEquals("C1.1", 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 testParseSimpleLinkTag() {
    WikiPageNode wikiPageNode = getWikiPageNode("link-1.creole");

    Assert.assertNotNull(wikiPageNode);

    ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0);

    LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0);

    Assert.assertEquals(1, lineNode.getChildASTNodesCount());

    LinkNode linkNode = (LinkNode) lineNode.getChildASTNode(0);

    Assert.assertEquals("link", linkNode.getLink());

    CollectionNode collectionNode = linkNode.getAltCollectionNode();

    Assert.assertNotNull(collectionNode);
    Assert.assertEquals(1, collectionNode.size());

    List<ASTNode> astNodes = collectionNode.getASTNodes();

    UnformattedTextNode unformattedTextNode = (UnformattedTextNode) astNodes.get(0);

    CollectionNode unformattedTextNodes = (CollectionNode) unformattedTextNode.getChildASTNode(0);

    unformattedTextNode = (UnformattedTextNode) unformattedTextNodes.get(0);

    Assert.assertEquals("alternative text", unformattedTextNode.getContent());
  }
  @Test
  public void testParseSimpleLinkTagWithoutDescription2() {
    WikiPageNode wikiPageNode = getWikiPageNode("link-3.creole");

    Assert.assertNotNull(wikiPageNode);

    ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0);

    LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0);

    Assert.assertEquals(5, lineNode.getChildASTNodesCount());

    List<ASTNode> astNodes = lineNode.getChildASTNodes();

    for (ASTNode astNode : astNodes) {
      if (!(astNode instanceof LinkNode)) {
        continue;
      }

      LinkNode linkNode = (LinkNode) astNode;

      Assert.assertEquals("L", linkNode.getLink());

      CollectionNode collectionNode = linkNode.getAltCollectionNode();

      Assert.assertNotNull(collectionNode);
      Assert.assertEquals(1, collectionNode.size());

      List<ASTNode> collectionNodeASTNodes = collectionNode.getASTNodes();

      UnformattedTextNode unformattedTextNode = (UnformattedTextNode) collectionNodeASTNodes.get(0);

      collectionNode = (CollectionNode) unformattedTextNode.getChildASTNode(0);

      unformattedTextNode = (UnformattedTextNode) collectionNode.get(0);

      Assert.assertEquals("A", unformattedTextNode.getContent());
    }
  }