1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.apache.maven.doxia.core; |
20 |
|
|
21 |
|
import java.util.Iterator; |
22 |
|
|
23 |
|
import org.apache.maven.doxia.parser.AbstractParserTest; |
24 |
|
import org.apache.maven.doxia.parser.Parser; |
25 |
|
import org.apache.maven.doxia.parser.Xhtml5BaseParser; |
26 |
|
import org.apache.maven.doxia.sink.impl.SinkEventElement; |
27 |
|
import org.apache.maven.doxia.sink.impl.SinkEventTestingSink; |
28 |
|
import org.junit.jupiter.api.BeforeEach; |
29 |
|
import org.junit.jupiter.api.Test; |
30 |
|
|
31 |
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
32 |
|
import static org.junit.jupiter.api.Assertions.assertFalse; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 4 |
Complexity Density: 0,14 |
|
37 |
|
public class Xhtml5BaseParserTest extends AbstractParserTest { |
38 |
|
|
39 |
|
private Xhtml5BaseParser parser; |
40 |
|
|
41 |
|
private final SinkEventTestingSink sink = new SinkEventTestingSink(); |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
43 |
2 |
@Override... |
44 |
|
protected Parser createParser() { |
45 |
2 |
parser = new Xhtml5BaseParser(); |
46 |
2 |
return parser; |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
2 |
@Override... |
50 |
|
protected String outputExtension() { |
51 |
2 |
return "xhtml"; |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
54 |
3 |
@BeforeEach... |
55 |
|
protected void setUp() throws Exception { |
56 |
3 |
parser = new Xhtml5BaseParser(); |
57 |
3 |
sink.reset(); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0,04 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void test() throws Exception { |
62 |
1 |
final String text = "<p>element {{< badge color=“secondary” text=“site.xml” />}}</p>"; |
63 |
|
|
64 |
1 |
parser.parse(text, sink); |
65 |
|
|
66 |
1 |
final Iterator<SinkEventElement> it = sink.getEventList().iterator(); |
67 |
|
|
68 |
1 |
SinkEventElement element = it.next(); |
69 |
1 |
assertEquals("paragraph", element.getName()); |
70 |
1 |
element = it.next(); |
71 |
1 |
assertEquals("text", element.getName()); |
72 |
1 |
assertEquals("element {{", element.getArgs()[0]); |
73 |
1 |
element = it.next(); |
74 |
1 |
assertEquals("text", element.getName()); |
75 |
1 |
assertEquals("<", element.getArgs()[0]); |
76 |
1 |
element = it.next(); |
77 |
1 |
assertEquals("text", element.getName()); |
78 |
1 |
assertEquals(" badge color=“secondary” text=“site.xml” /", element.getArgs()[0]); |
79 |
1 |
element = it.next(); |
80 |
1 |
assertEquals("text", element.getName()); |
81 |
1 |
assertEquals(">", element.getArgs()[0]); |
82 |
1 |
element = it.next(); |
83 |
1 |
assertEquals("text", element.getName()); |
84 |
1 |
assertEquals("}}", element.getArgs()[0]); |
85 |
1 |
element = it.next(); |
86 |
1 |
assertEquals("paragraph_", element.getName()); |
87 |
1 |
assertFalse(it.hasNext()); |
88 |
|
} |
89 |
|
} |