1+ package org .gitlab4j .api ;
2+
3+ import org .gitlab4j .api .models .Markdown ;
4+ import org .junit .Before ;
5+ import org .junit .BeforeClass ;
6+ import org .junit .Test ;
7+ import org .junit .experimental .categories .Category ;
8+
9+ import static org .junit .Assert .*;
10+ import static org .junit .Assume .assumeTrue ;
11+
12+ @ Category (IntegrationTest .class )
13+ public class TestMarkdownApi extends AbstractIntegrationTest {
14+
15+ private static final String EXPECTED_HTML_FOR_SPECIAL = "<p data-sourcepos=\" 1:1-1:104\" dir=\" auto\" >Hello world! <gl-emoji title=\" party popper\" data-name=\" tada\" data-unicode-version=\" 6.0\" >🎉</gl-emoji> <code>xml <profiles> <version>${maven-surefire-plugin.version}</version> </profiles></code></p>" ;
16+ public static final String SPECIAL_CHAR_EXAMPLE = "Hello world! :tada: ```xml <profiles> <version>${maven-surefire-plugin.version}</version> </profiles>```" ;
17+
18+ public static final String NORMAL_HTML_EXAMPLE = "<h1 data-sourcepos=\" 1:1-1:4\" dir=\" auto\" >\n " +
19+ "<a id=\" user-content-h1\" class=\" anchor\" href=\" #h1\" aria-hidden=\" true\" ></a>H1</h1>\n " +
20+ "<h2 data-sourcepos=\" 2:2-2:6\" dir=\" auto\" >\n " +
21+ "<a id=\" user-content-h2\" class=\" anchor\" href=\" #h2\" aria-hidden=\" true\" ></a>H2</h2>\n " +
22+ "<h3 data-sourcepos=\" 3:2-3:7\" dir=\" auto\" >\n " +
23+ "<a id=\" user-content-h3\" class=\" anchor\" href=\" #h3\" aria-hidden=\" true\" ></a>H3</h3>\n " +
24+ "<h4 data-sourcepos=\" 4:2-4:8\" dir=\" auto\" >\n " +
25+ "<a id=\" user-content-h4\" class=\" anchor\" href=\" #h4\" aria-hidden=\" true\" ></a>H4</h4>\n " +
26+ "<h5 data-sourcepos=\" 5:2-5:9\" dir=\" auto\" >\n " +
27+ "<a id=\" user-content-h5\" class=\" anchor\" href=\" #h5\" aria-hidden=\" true\" ></a>H5</h5>\n " +
28+ "<h6 data-sourcepos=\" 6:2-6:10\" dir=\" auto\" >\n " +
29+ "<a id=\" user-content-h6\" class=\" anchor\" href=\" #h6\" aria-hidden=\" true\" ></a>H6</h6>" ;
30+
31+ private static GitLabApi gitLabApi ;
32+
33+ @ BeforeClass
34+ public static void setUp () throws Exception {
35+ gitLabApi = baseTestSetup ();
36+ }
37+
38+ @ Before
39+ public void beforeMethod () {
40+ assumeTrue (gitLabApi != null );
41+ }
42+
43+ @ Test
44+ public void testMarkdownWithSpecialCharacters () throws GitLabApiException {
45+ Markdown markdown = gitLabApi .getMarkdownApi ().getMarkdown (SPECIAL_CHAR_EXAMPLE );
46+
47+ assertEquals (EXPECTED_HTML_FOR_SPECIAL , markdown .getHtml ());
48+ }
49+
50+ @ Test
51+ public void testMarkdownWithNormalText () throws GitLabApiException {
52+ Markdown markdown = gitLabApi .getMarkdownApi ().getMarkdown ("# H1 \n ## H2 \n ### H3 \n #### H4 \n ##### H5 \n ###### H6" );
53+
54+ assertEquals (NORMAL_HTML_EXAMPLE , markdown .getHtml ());
55+ }
56+ }
0 commit comments