MarkdownMarkup extends AbstractMarkup { @Override public String convertAsHtml(String markupString) { if (markupString == null) throw new IllegalArgumentException("Can not convert " + getName() + " to HTML : the String is null"); final Parser parser = Parser.builder().extensions(extensions).build(); final Node node = parser.parse(markupString); final HtmlRenderer renderer = HtmlRenderer.builder().extensions(extensions).build(); return renderer.render(node).trim(); } MarkdownMarkup(); @Override String convertAsHtml(String markupString);  }
@Test void generateWithNull() { assertThrows(IllegalArgumentException.class, () -> markup.convertAsHtml(null)); }
@Test void generateH1() { final String result = markup.convertAsHtml("# A title"); assertEquals("<h1>A title</h1>", result); }
@Test void generateH2() { final String result = markup.convertAsHtml("## A title"); assertEquals("<h2>A title</h2>", result); }
@Test void generateInlineCode() { final String result = markup.convertAsHtml("`public class Java { }`"); assertEquals("<p><code>public class Java { }</code></p>", result); }
@Test void generateCodeBloc() { final String result = markup.convertAsHtml(" final String s;"); assertEquals("<pre><code>final String s;\n</code></pre>", result); }
@Test void generateStrong() { final String result = markup.convertAsHtml("*Strong text*"); assertEquals("<p><em>Strong text</em></p>", result); }
@Test void generateUnorderedList() { final String result = markup.convertAsHtml("* One\n* Two"); assertEquals("<ul>\n<li>One</li>\n<li>Two</li>\n</ul>", result); }