1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.javadoc;
21
22 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocRegexpCheck.MSG_JAVADOC_REGEXP;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
28
29 public class JavadocRegexpCheckExamplesTest extends AbstractExamplesModuleTestSupport {
30
31 @Override
32 public String getPackageLocation() {
33 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocregexp";
34 }
35
36 @Test
37 public void testExample1() throws Exception {
38 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
39 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
40 }
41
42 @Test
43 public void testExample2() throws Exception {
44 final String format = "</p>";
45 final String[] expected = {
46 "19: " + getCheckMessage(MSG_JAVADOC_REGEXP, format),
47 };
48
49 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
50 }
51
52 @Test
53 public void testExample3() throws Exception {
54 final String format = "(^|\\W)(AKA)(\\W|$)";
55 final String[] expected = {
56 "25: " + getCheckMessage(MSG_JAVADOC_REGEXP, format),
57 };
58
59 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
60 }
61
62 @Test
63 public void testExample4() throws Exception {
64 final String format = "aka";
65 final String[] expected = {
66 "25: " + getCheckMessage(MSG_JAVADOC_REGEXP, format),
67 "31: " + getCheckMessage(MSG_JAVADOC_REGEXP, format),
68 };
69
70 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
71 }
72
73 }