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.google.common.truth.Truth.assertWithMessage;
23 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck.MSG_KEY;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28 import com.puppycrawl.tools.checkstyle.api.TokenTypes;
29 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
30
31 public class JavadocTagContinuationIndentationCheckTest
32 extends AbstractModuleTestSupport {
33
34 @Override
35 protected String getPackageLocation() {
36 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation";
37 }
38
39 @Test
40 public void testGetRequiredTokens() {
41 final JavadocTagContinuationIndentationCheck checkObj =
42 new JavadocTagContinuationIndentationCheck();
43 final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
44 assertWithMessage("Default required tokens are invalid")
45 .that(checkObj.getRequiredTokens())
46 .isEqualTo(expected);
47 }
48
49 @Test
50 public void testFp() throws Exception {
51 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
52 verifyWithInlineConfigParser(
53 getPath("InputJavadocTagContinuationIndentationGuavaFalsePositive.java"),
54 expected);
55 }
56
57 @Test
58 public void testCheck() throws Exception {
59 final String[] expected = {
60 "55: " + getCheckMessage(MSG_KEY, 4),
61 "117: " + getCheckMessage(MSG_KEY, 4),
62 "120: " + getCheckMessage(MSG_KEY, 4),
63 "211: " + getCheckMessage(MSG_KEY, 4),
64 "214: " + getCheckMessage(MSG_KEY, 4),
65 "229: " + getCheckMessage(MSG_KEY, 4),
66 "231: " + getCheckMessage(MSG_KEY, 4),
67 "293: " + getCheckMessage(MSG_KEY, 4),
68 "296: " + getCheckMessage(MSG_KEY, 4),
69 "298: " + getCheckMessage(MSG_KEY, 4),
70 "318: " + getCheckMessage(MSG_KEY, 4),
71 "330: " + getCheckMessage(MSG_KEY, 4),
72 "332: " + getCheckMessage(MSG_KEY, 4),
73 "350: " + getCheckMessage(MSG_KEY, 4),
74 };
75 verifyWithInlineConfigParser(
76 getPath("InputJavadocTagContinuationIndentation.java"),
77 expected);
78 }
79
80 @Test
81 public void testCheckWithOffset3() throws Exception {
82 final String[] expected = {
83 "15: " + getCheckMessage(MSG_KEY, 3),
84 "27: " + getCheckMessage(MSG_KEY, 3),
85 };
86 verifyWithInlineConfigParser(
87 getPath("InputJavadocTagContinuationIndentationOffset3.java"),
88 expected);
89 }
90
91 @Test
92 public void testCheckWithDescription() throws Exception {
93 final String[] expected = {
94 "16: " + getCheckMessage(MSG_KEY, 4),
95 "17: " + getCheckMessage(MSG_KEY, 4),
96 "18: " + getCheckMessage(MSG_KEY, 4),
97 "47: " + getCheckMessage(MSG_KEY, 4),
98 "49: " + getCheckMessage(MSG_KEY, 4),
99 "50: " + getCheckMessage(MSG_KEY, 4),
100 "70: " + getCheckMessage(MSG_KEY, 4),
101 "71: " + getCheckMessage(MSG_KEY, 4),
102 };
103 verifyWithInlineConfigParser(
104 getPath("InputJavadocTagContinuationIndentationDescription.java"),
105 expected);
106 }
107
108 @Test
109 public void testBlockTag() throws Exception {
110 final String[] expected = {
111 "21: " + getCheckMessage(MSG_KEY, 4),
112 "32: " + getCheckMessage(MSG_KEY, 4),
113 "42: " + getCheckMessage(MSG_KEY, 4),
114 "62: " + getCheckMessage(MSG_KEY, 4),
115 "74: " + getCheckMessage(MSG_KEY, 4),
116 "75: " + getCheckMessage(MSG_KEY, 4),
117 "86: " + getCheckMessage(MSG_KEY, 4),
118 "87: " + getCheckMessage(MSG_KEY, 4),
119 "88: " + getCheckMessage(MSG_KEY, 4),
120 "89: " + getCheckMessage(MSG_KEY, 4),
121 "90: " + getCheckMessage(MSG_KEY, 4),
122 "91: " + getCheckMessage(MSG_KEY, 4),
123 "92: " + getCheckMessage(MSG_KEY, 4),
124 "93: " + getCheckMessage(MSG_KEY, 4),
125 "94: " + getCheckMessage(MSG_KEY, 4),
126 "95: " + getCheckMessage(MSG_KEY, 4),
127 "96: " + getCheckMessage(MSG_KEY, 4),
128 "97: " + getCheckMessage(MSG_KEY, 4),
129 "98: " + getCheckMessage(MSG_KEY, 4),
130 "99: " + getCheckMessage(MSG_KEY, 4),
131 "104: " + getCheckMessage(MSG_KEY, 4),
132 "105: " + getCheckMessage(MSG_KEY, 4),
133 };
134 verifyWithInlineConfigParser(
135 getPath("InputJavadocTagContinuationIndentationBlockTag.java"),
136 expected);
137 }
138
139 @Test
140 public void testContinuationIndentation() throws Exception {
141 final String[] expected = {
142 "23: " + getCheckMessage(MSG_KEY, 4),
143 };
144 verifyWithInlineConfigParser(
145 getPath("InputJavadocTagContinuationIndentation1.java"),
146 expected);
147 }
148
149 @Test
150 public void testJavadocTagContinuationIndentationCheck1() throws Exception {
151 final String[] expected = {
152 "16: " + getCheckMessage(MSG_KEY, 4),
153 };
154 verifyWithInlineConfigParser(
155 getPath("InputJavadocTagContinuationIndentationCheck1.java"),
156 expected);
157 }
158
159 @Test
160 public void testJavadocTagContinuationIndentationCheckHtml() throws Exception {
161 final String[] expected = {
162 "15: " + getCheckMessage(MSG_KEY, 4),
163 "18: " + getCheckMessage(MSG_KEY, 4),
164 "28: " + getCheckMessage(MSG_KEY, 4),
165 "29: " + getCheckMessage(MSG_KEY, 4),
166 "30: " + getCheckMessage(MSG_KEY, 4),
167 "50: " + getCheckMessage(MSG_KEY, 4),
168 "51: " + getCheckMessage(MSG_KEY, 4),
169 "52: " + getCheckMessage(MSG_KEY, 4),
170 "63: " + getCheckMessage(MSG_KEY, 4),
171 "64: " + getCheckMessage(MSG_KEY, 4),
172 "65: " + getCheckMessage(MSG_KEY, 4),
173 "75: " + getCheckMessage(MSG_KEY, 4),
174 "76: " + getCheckMessage(MSG_KEY, 4),
175 };
176 verifyWithInlineConfigParser(
177 getPath("InputJavadocTagContinuationIndentationCheckHtml.java"),
178 expected);
179 }
180
181 @Test
182 public void testJavadocTagContinuationIndentationCheckPreTag() throws Exception {
183 final String[] expected = {
184 "91: " + getCheckMessage(MSG_KEY, 4),
185 "100: " + getCheckMessage(MSG_KEY, 4),
186 "101: " + getCheckMessage(MSG_KEY, 4),
187 "102: " + getCheckMessage(MSG_KEY, 4),
188 };
189 verifyWithInlineConfigParser(
190 getPath("InputJavadocTagContinuationIndentationPreTag.java"), expected);
191 }
192
193 @Test
194 public void testJavadocTagContinuationIndentationCheckPreTag2() throws Exception {
195 final String[] expected = {
196 "32: " + getCheckMessage(MSG_KEY, 4),
197 "33: " + getCheckMessage(MSG_KEY, 4),
198 "34: " + getCheckMessage(MSG_KEY, 4),
199 "35: " + getCheckMessage(MSG_KEY, 4),
200 "70: " + getCheckMessage(MSG_KEY, 4),
201 "78: " + getCheckMessage(MSG_KEY, 4),
202 "79: " + getCheckMessage(MSG_KEY, 4),
203 "80: " + getCheckMessage(MSG_KEY, 4),
204 "81: " + getCheckMessage(MSG_KEY, 4),
205 "82: " + getCheckMessage(MSG_KEY, 4),
206 "83: " + getCheckMessage(MSG_KEY, 4),
207 "84: " + getCheckMessage(MSG_KEY, 4),
208 "85: " + getCheckMessage(MSG_KEY, 4),
209 "90: " + getCheckMessage(MSG_KEY, 4),
210 "91: " + getCheckMessage(MSG_KEY, 4),
211 "92: " + getCheckMessage(MSG_KEY, 4),
212 };
213 verifyWithInlineConfigParser(
214 getPath("InputJavadocTagContinuationIndentationPreTag2.java"), expected);
215 }
216
217 @Test
218 public void testJavadocTagContinuationIndentationCheckPreTag3() throws Exception {
219 final String[] expected = {
220 "34: " + getCheckMessage(MSG_KEY, 4),
221 "35: " + getCheckMessage(MSG_KEY, 4),
222 "36: " + getCheckMessage(MSG_KEY, 4),
223 "37: " + getCheckMessage(MSG_KEY, 4),
224 };
225 verifyWithInlineConfigParser(
226 getPath("InputJavadocTagContinuationIndentationPreTag3.java"), expected);
227 }
228 }