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