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.JavadocMethodCheck.MSG_EXPECTED_TAG;
23 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_RETURN_EXPECTED;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
28 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
29
30 public class JavadocMethodCheckExamplesTest extends AbstractExamplesModuleTestSupport {
31 @Override
32 public String getPackageLocation() {
33 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod";
34 }
35
36 @Test
37 public void testExample1() throws Exception {
38 final String[] expected = {
39 "16:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
40 "19: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
41 "19:21: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
42 "30: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
43 "36:15: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
44 "41: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
45 };
46
47 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
48 }
49
50 @Test
51 public void testExample2() throws Exception {
52 final String[] expected = {
53 "22: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
54 "44: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
55 };
56
57 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
58 }
59
60 @Test
61 public void testExample3() throws Exception {
62 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
63 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
64 }
65
66 @Test
67 public void testExample4() throws Exception {
68 final String[] expected = {
69 "18:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
70 "21:21: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
71 "38:15: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
72 };
73
74 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
75 }
76
77 @Test
78 public void testExample5() throws Exception {
79 final String[] expected = {
80 "18:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
81 "21: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
82 "21:21: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
83 "38:15: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
84 "43: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
85 };
86
87 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
88 }
89
90 @Test
91 public void testExample6() throws Exception {
92 final String[] expected = {
93 "18:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
94 };
95
96 verifyWithInlineConfigParser(getPath("Example6.java"), expected);
97 }
98
99 @Test
100 public void testExample7() throws Exception {
101 final String[] expected = {
102 "18:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
103 "21: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
104 "21:21: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
105 "21:32: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IOException"),
106 "32: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
107 "38:15: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
108 "43: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
109 };
110
111 verifyWithInlineConfigParser(getPath("Example7.java"), expected);
112 }
113
114 @Test
115 public void testExample8() throws Exception {
116 final String[] expected = {
117 "18:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "x"),
118 "21: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
119 "21:21: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
120 "32: " + getCheckMessage(MSG_RETURN_EXPECTED, "@return"),
121 "38:15: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
122 };
123 verifyWithInlineConfigParser(getPath("Example8.java"), expected);
124 }
125 }