1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.tools.plugin.generator;
20
21 import org.junit.jupiter.api.Test;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNull;
25
26 class HtmlToPlainTextConverterTest {
27 private final Converter converter;
28
29 public HtmlToPlainTextConverterTest() {
30 converter = new HtmlToPlainTextConverter();
31 }
32
33 @Test
34 void testConvertWithCodeAndLink() {
35 String test =
36 "This is a <code>code</code> and <a href=\"https://javadoc.example.com/some/javadoc.html\">Link</a>";
37 assertEquals(
38 "This is a code and Link <https://javadoc.example.com/some/javadoc.html>", converter.convert(test));
39 }
40
41 @Test
42 void testMultilineJavadocAndWordWrap() {
43 String test =
44 "Generates a <a href=\"https://jackrabbit.apache.org/jcr/node-type-notation.html\">CND file</a> containing all\n"
45 + "used node types and namespaces. It uses the <a href=\"https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.7.11%20Standard%20Application%20Node%20Types\">default namespaces and node types</a>\n"
46 + "and in addition some provided ones as source node type and namespace registry.";
47 assertEquals(
48 "Generates a CND file <https://jackrabbit.apache.org/jcr/node-type-notation.html> "
49 + "containing all used node types and namespaces. It uses the default namespaces"
50 + " and node types <https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.7.11%20Standard%20Application%20Node%20Types>"
51 + " and in addition some provided ones as source node type and namespace registry.",
52 converter.convert(test));
53 }
54
55 @Test
56 void testRelativeUrl() {
57 String test = "<a href=\"#field\">field</a>";
58 assertEquals("field", converter.convert(test));
59 }
60
61 @Test
62 void testNullValue() {
63 assertNull(converter.convert(null));
64 }
65
66 @Test
67 void testExplicitNewline() {
68 String test =
69 "Some \"quotation\" marks and backslashes '\\\\', some <strong>important</strong> javadoc<br> and an\n"
70 + "inline link to foo";
71 assertEquals(
72 "Some \"quotation\" marks and backslashes '\\\\', some important javadoc\n"
73 + "and an inline link to foo",
74 converter.convert(test));
75 }
76 }