1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.apache.maven.doxia.module.markdown; |
20 |
|
|
21 |
|
import javax.inject.Inject; |
22 |
|
|
23 |
|
import java.io.Reader; |
24 |
|
import java.io.StringReader; |
25 |
|
|
26 |
|
import com.google.common.base.Throwables; |
27 |
|
import org.apache.maven.doxia.parser.Parser; |
28 |
|
import org.devacfr.testing.jupiter.ParserTestCase; |
29 |
|
import org.jsoup.Jsoup; |
30 |
|
import org.junit.jupiter.api.Test; |
31 |
|
|
32 |
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
33 |
|
|
|
|
| 83,3% |
Uncovered Elements: 4 (24) |
Complexity: 9 |
Complexity Density: 0,47 |
|
34 |
|
public class MarkdownParserTest extends ParserTestCase { |
35 |
|
|
36 |
|
@Inject |
37 |
|
private MarkdownParser parser; |
38 |
|
|
39 |
|
|
40 |
|
@inheritDoc |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
2 |
@Override... |
43 |
|
protected Parser createParser() { |
44 |
2 |
return parser; |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
@inheritDoc |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
2 |
@Override... |
51 |
|
protected String outputExtension() { |
52 |
2 |
return MarkdownParserModule.FILE_EXTENSION; |
53 |
|
} |
54 |
|
|
|
|
| 71,4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0,29 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void shouldParseToHtml() { |
57 |
1 |
assertNotNull(parser); |
58 |
1 |
verify(content -> { |
59 |
1 |
try { |
60 |
1 |
final String html = parseFileToHtml(content); |
61 |
1 |
return Jsoup.parse(html).html(); |
62 |
|
} catch (final Exception e) { |
63 |
0 |
Throwables.throwIfUnchecked(e); |
64 |
0 |
throw new RuntimeException(e); |
65 |
|
} |
66 |
|
}, "md"); |
67 |
|
} |
68 |
|
|
|
|
| 71,4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0,29 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void shouldParseSnippetToHtml() { |
71 |
1 |
assertNotNull(parser); |
72 |
1 |
verify(content -> { |
73 |
1 |
try { |
74 |
1 |
final String html = parseFileToHtml(content); |
75 |
1 |
return Jsoup.parse(html).html(); |
76 |
|
} catch (final Exception e) { |
77 |
0 |
Throwables.throwIfUnchecked(e); |
78 |
0 |
throw new RuntimeException(e); |
79 |
|
} |
80 |
|
}, "md"); |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 3 |
Complexity Density: 1 |
|
83 |
2 |
protected String parseFileToHtml(final String content) throws Exception {... |
84 |
2 |
try (Reader reader = new StringReader(content)) { |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
2 |
return parser.toHtml(reader).toString(); |
89 |
|
} |
90 |
|
} |
91 |
|
} |