View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2024 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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.JavadocMethodCheck.MSG_DUPLICATE_TAG;
24  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_EXPECTED_TAG;
25  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_INVALID_INHERIT_DOC;
26  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_RETURN_EXPECTED;
27  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_UNUSED_TAG;
28  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_UNUSED_TAG_GENERAL;
29  
30  import java.lang.reflect.Constructor;
31  import java.lang.reflect.Method;
32  
33  import org.junit.jupiter.api.Test;
34  
35  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
36  import com.puppycrawl.tools.checkstyle.api.TokenTypes;
37  import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
38  
39  public class JavadocMethodCheckTest extends AbstractModuleTestSupport {
40  
41      @Override
42      protected String getPackageLocation() {
43          return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod";
44      }
45  
46      @Test
47      public void testGetAcceptableTokens() {
48          final JavadocMethodCheck javadocMethodCheck = new JavadocMethodCheck();
49  
50          final int[] actual = javadocMethodCheck.getAcceptableTokens();
51          final int[] expected = {
52              TokenTypes.CLASS_DEF,
53              TokenTypes.ENUM_DEF,
54              TokenTypes.INTERFACE_DEF,
55              TokenTypes.METHOD_DEF,
56              TokenTypes.CTOR_DEF,
57              TokenTypes.ANNOTATION_FIELD_DEF,
58              TokenTypes.RECORD_DEF,
59              TokenTypes.COMPACT_CTOR_DEF,
60          };
61  
62          assertWithMessage("Default acceptable tokens are invalid")
63              .that(actual)
64              .isEqualTo(expected);
65      }
66  
67      @Test
68      public void extendAnnotationTest() throws Exception {
69          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
70          verifyWithInlineConfigParser(
71                  getPath("InputJavadocMethodExtendAnnotation.java"), expected);
72      }
73  
74      @Test
75      public void allowedAnnotationsTest() throws Exception {
76          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
77          verifyWithInlineConfigParser(
78                  getPath("InputJavadocMethodAllowedAnnotations.java"), expected);
79      }
80  
81      @Test
82      public void testThrowsDetection() throws Exception {
83          final String[] expected = {
84              "25:19: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
85                      "UnsupportedOperationException"),
86              "37:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
87                      "UnsupportedOperationException"),
88              "41:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
89                      "IllegalArgumentException"),
90              "55:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
91                      "UnsupportedOperationException"),
92              "60:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
93                      "IllegalArgumentException"),
94              "72:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
95                      "UnsupportedOperationException"),
96              "76:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
97                      "IllegalArgumentException"),
98              "88:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
99                      "UnsupportedOperationException"),
100             "92:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
101                     "IllegalArgumentException"),
102             "105:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
103                     "IllegalArgumentException"),
104             "120:31: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
105                     "IllegalArgumentException"),
106             "133:19: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
107                     "UnsupportedOperationException"),
108             "149:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
109                     "RuntimeException"),
110             "163:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
111                     "RuntimeException"),
112         };
113         verifyWithInlineConfigParser(
114                 getPath("InputJavadocMethodThrowsDetection.java"), expected);
115     }
116 
117     @Test
118     public void testExtraThrows() throws Exception {
119         final String[] expected = {
120             "54:56: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"),
121             "70:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
122             "83:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
123             "96:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
124                     "java.lang.IllegalArgumentException"),
125             "137:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "FileNotFoundException"),
126         };
127         verifyWithInlineConfigParser(
128                 getPath("InputJavadocMethodExtraThrows.java"), expected);
129     }
130 
131     @Test
132     public void testIgnoreThrows() throws Exception {
133         final String[] expected = {
134             "40:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
135             "43:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"),
136             "60:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
137             "141:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
138             "198:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
139         };
140         verifyWithInlineConfigParser(
141                 getPath("InputJavadocMethodIgnoreThrows.java"), expected);
142     }
143 
144     @Test
145     public void testTags() throws Exception {
146         final String[] expected = {
147             "30:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"),
148             "37: " + getCheckMessage(MSG_RETURN_EXPECTED),
149             "46: " + getCheckMessage(MSG_RETURN_EXPECTED),
150             "53:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "Exception"),
151             "62:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "Exception"),
152             "68:16: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "Exception"),
153             "68:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "NullPointerException"),
154             "73:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aOne"),
155             "81:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aOne"),
156             "85:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "WrongParam"),
157             "87:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aOne"),
158             "87:33: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aTwo"),
159             "93:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "Unneeded"),
160             "94: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
161             "103:8: " + getCheckMessage(MSG_DUPLICATE_TAG, "@return"),
162             "273:28: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IOException"),
163             "279:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "aParam"),
164             "322: " + getCheckMessage(MSG_RETURN_EXPECTED),
165             "322:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aParam"),
166             "361:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
167             "400:8: " + getCheckMessage(MSG_DUPLICATE_TAG, "@return"),
168         };
169 
170         verifyWithInlineConfigParser(
171                 getPath("InputJavadocMethodTags.java"), expected);
172     }
173 
174     @Test
175     public void testStrictJavadoc() throws Exception {
176         final String[] expected = {
177             "77:29: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
178             "82:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
179             "87:41: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
180             "92:37: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
181             "102:32: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
182         };
183         verifyWithInlineConfigParser(
184                 getPath("InputJavadocMethodPublicOnly.java"), expected);
185     }
186 
187     @Test
188     public void testNoJavadoc() throws Exception {
189         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
190         verifyWithInlineConfigParser(
191                 getPath("InputJavadocMethodPublicOnly1.java"), expected);
192     }
193 
194     // pre 1.4 relaxed mode is roughly equivalent with check=protected
195     @Test
196     public void testRelaxedJavadoc() throws Exception {
197         final String[] expected = {
198             "87:41: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
199             "92:37: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"),
200         };
201         verifyWithInlineConfigParser(
202                 getPath("InputJavadocMethodProtectedScopeJavadoc.java"), expected);
203     }
204 
205     @Test
206     public void testScopeInnerInterfacesPublic() throws Exception {
207         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
208         verifyWithInlineConfigParser(
209                 getPath("InputJavadocMethodScopeInnerInterfaces.java"), expected);
210     }
211 
212     @Test
213     public void testScopeAnonInnerPrivate() throws Exception {
214         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
215         verifyWithInlineConfigParser(
216                 getPath("InputJavadocMethodScopeAnonInner.java"), expected);
217     }
218 
219     @Test
220     public void testScopes() throws Exception {
221         final String[] expected = {
222             "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
223             "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
224             "31: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
225             "33: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
226         };
227         verifyWithInlineConfigParser(
228                 getPath("InputJavadocMethodNoJavadocDefault.java"), expected);
229     }
230 
231     @Test
232     public void testScopes2() throws Exception {
233         final String[] expected = {
234             "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
235             "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
236         };
237         verifyWithInlineConfigParser(
238                 getPath("InputJavadocMethodNoJavadocProtectedScope.java"), expected);
239     }
240 
241     @Test
242     public void testExcludeScope() throws Exception {
243         final String[] expected = {
244             "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
245             "31: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
246             "33: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
247         };
248         verifyWithInlineConfigParser(
249                 getPath("InputJavadocMethodNoJavadocOnlyPrivateScope.java"), expected);
250     }
251 
252     @Test
253     public void testAllowMissingJavadocTags() throws Exception {
254         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
255         verifyWithInlineConfigParser(
256                 getPath("InputJavadocMethodMissingJavadocNoMissingTags.java"),
257                 expected);
258     }
259 
260     @Test
261     public void testSurroundingAccessModifier() throws Exception {
262         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
263         verifyWithInlineConfigParser(
264                 getPath("InputJavadocMethodSurroundingAccessModifier.java"), expected);
265     }
266 
267     @Test
268     public void testDoAllowMissingJavadocTagsByDefault() throws Exception {
269         final String[] expected = {
270             "23: " + getCheckMessage(MSG_RETURN_EXPECTED),
271             "34:26: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "number"),
272             "65: " + getCheckMessage(MSG_RETURN_EXPECTED),
273             "75: " + getCheckMessage(MSG_RETURN_EXPECTED),
274             "87: " + getCheckMessage(MSG_RETURN_EXPECTED),
275         };
276         verifyWithInlineConfigParser(
277                 getPath("InputJavadocMethodMissingJavadocTagsDefault.java"), expected);
278     }
279 
280     @Test
281     public void testSetterGetter() throws Exception {
282         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
283         verifyWithInlineConfigParser(
284                 getPath("InputJavadocMethodSetterGetter.java"), expected);
285     }
286 
287     @Test
288     public void testTypeParamsTags() throws Exception {
289         final String[] expected = {
290             "37:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<BB>"),
291             "40:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "<Z>"),
292             "65:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<Z"),
293             "68:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "<Z>"),
294         };
295         verifyWithInlineConfigParser(
296                 getPath("InputJavadocMethodTypeParamsTags.java"), expected);
297     }
298 
299     @Test
300     public void testAllowUndocumentedParamsTags() throws Exception {
301         final String[] expected = {
302             "33:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam"),
303             "34:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam2"),
304             "36:13: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam3"),
305             "37:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam4"),
306             "65:7: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "t"),
307             "68:34: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "w"),
308             "77:7: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "x"),
309             "79:34: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "y"),
310         };
311         verifyWithInlineConfigParser(
312                 getPath("InputJavadocMethodParamsTags.java"), expected);
313     }
314 
315     @Test
316     public void test11684081() throws Exception {
317         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
318         verifyWithInlineConfigParser(
319                 getPath("InputJavadocMethod_01.java"), expected);
320     }
321 
322     @Test
323     public void test11684082() throws Exception {
324         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
325         verifyWithInlineConfigParser(
326                 getPath("InputJavadocMethod_02.java"), expected);
327     }
328 
329     @Test
330     public void test11684083() throws Exception {
331         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
332         verifyWithInlineConfigParser(
333                 getPath("InputJavadocMethod_03.java"), expected);
334     }
335 
336     @Test
337     public void testGenerics() throws Exception {
338         final String[] expected = {
339             "29:34: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "RE"),
340             "46:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "<NPE>"),
341             "57:38: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "RuntimeException"),
342             "58:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "java.lang.RuntimeException"),
343         };
344         verifyWithInlineConfigParser(
345                 getPath("InputJavadocMethodGenerics.java"), expected);
346     }
347 
348     @Test
349     public void test1379666() throws Exception {
350         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
351         verifyWithInlineConfigParser(
352                 getPath("InputJavadocMethod_1379666.java"), expected);
353     }
354 
355     @Test
356     public void testInheritDoc() throws Exception {
357         final String[] expected = {
358             "18:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
359             "23:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
360             "43:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
361             "48:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
362             "54:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
363             "59:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC),
364         };
365         verifyWithInlineConfigParser(
366                 getPath("InputJavadocMethodInheritDoc.java"), expected);
367     }
368 
369     @Test
370     public void testAllowToSkipOverridden() throws Exception {
371         final String[] expected = {
372             "19:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"),
373             "30:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"),
374         };
375         verifyWithInlineConfigParser(
376                 getPath("InputJavadocMethodsNotSkipWritten.java"), expected);
377     }
378 
379     @Test
380     public void testJava8ReceiverParameter() throws Exception {
381         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
382         verifyWithInlineConfigParser(
383                 getPath("InputJavadocMethodReceiverParameter.java"), expected);
384     }
385 
386     @Test
387     public void testJavadocInMethod() throws Exception {
388         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
389         verifyWithInlineConfigParser(
390                 getPath("InputJavadocMethodJavadocInMethod.java"), expected);
391     }
392 
393     @Test
394     public void testConstructor() throws Exception {
395         final String[] expected = {
396             "21:49: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
397             "24:50: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"),
398         };
399         verifyWithInlineConfigParser(
400                 getPath("InputJavadocMethodConstructor.java"), expected);
401     }
402 
403     @Test
404     public void testJavadocMethodRecordsAndCompactCtors() throws Exception {
405         final String[] expected = {
406             "29:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
407             "43:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws",
408                     "java.lang.IllegalArgumentException"),
409             "55: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
410             "63:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
411             "73: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL),
412             "81:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
413             "91:12: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "properties"),
414             "96:35: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "myInt"),
415             "101:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"),
416         };
417         verifyWithInlineConfigParser(
418                 getNonCompilablePath("InputJavadocMethodRecordsAndCompactCtors.java"), expected);
419     }
420 
421     @Test
422     public void testGetRequiredTokens() {
423         final int[] expected = {
424             TokenTypes.CLASS_DEF,
425             TokenTypes.INTERFACE_DEF,
426             TokenTypes.ENUM_DEF,
427             TokenTypes.RECORD_DEF,
428         };
429         final JavadocMethodCheck check = new JavadocMethodCheck();
430         final int[] actual = check.getRequiredTokens();
431         assertWithMessage("Required tokens differ from expected")
432             .that(actual)
433             .isEqualTo(expected);
434     }
435 
436     @Test
437     public void testTokenToString() throws Exception {
438         final Class<?> tokenType = Class.forName("com.puppycrawl.tools.checkstyle.checks.javadoc."
439                 + "JavadocMethodCheck$Token");
440         final Constructor<?> tokenConstructor = tokenType.getDeclaredConstructor(String.class,
441                 int.class, int.class);
442         tokenConstructor.setAccessible(true);
443         final Object token = tokenConstructor.newInstance("tokenName", 1, 1);
444         final Method toString = token.getClass().getDeclaredMethod("toString");
445         final String result = (String) toString.invoke(token);
446         assertWithMessage("Invalid toString result")
447             .that(result)
448             .isEqualTo("Token[tokenName(1x1)]");
449     }
450 
451     @Test
452     public void testWithoutLogErrors() throws Exception {
453         verifyWithInlineConfigParser(
454                 getPath("InputJavadocMethodLoadErrors.java"),
455                 CommonUtil.EMPTY_STRING_ARRAY);
456     }
457 
458     @Test
459     public void testCompilationUnit() throws Exception {
460         verifyWithInlineConfigParser(
461                 getNonCompilablePath("InputJavadocMethodCompilationUnit.java"),
462                 CommonUtil.EMPTY_STRING_ARRAY);
463     }
464 
465     @Test
466     public void testDefaultAccessModifier() throws Exception {
467         final String[] expected = {
468             "21:32: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "a"),
469             "26:43: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "b"),
470         };
471         verifyWithInlineConfigParser(
472                 getPath("InputJavadocMethodDefaultAccessModifier.java"), expected);
473     }
474 
475     @Test
476     public void testAccessModifierEnum() throws Exception {
477         final String[] expected = {
478             "27:17: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "i"),
479         };
480         verifyWithInlineConfigParser(
481                 getPath("InputJavadocMethodEnum.java"), expected);
482     }
483 
484     @Test
485     public void testCustomMessages() throws Exception {
486         final String msgReturnExpectedCustom =
487             "@return tag should be present and have description :)";
488         final String msgUnusedTagCustom = "Unused @param tag for 'unused' :)";
489         final String msgExpectedTagCustom = "Expected @param tag for 'a' :)";
490         final String[] expected = {
491             "20: " + msgReturnExpectedCustom,
492             "24:9: " + msgUnusedTagCustom,
493             "31:22: " + msgExpectedTagCustom,
494         };
495 
496         verifyWithInlineConfigParser(
497             getPath("InputJavadocMethodCustomMessage.java"), expected);
498     }
499 
500     @Test
501     public void test1() throws Exception {
502         final String[] expected = {
503             "23: " + getCheckMessage(MSG_RETURN_EXPECTED),
504         };
505         verifyWithInlineConfigParser(
506                 getPath("InputJavadocMethod1.java"), expected);
507     }
508 
509     @Test
510     public void test2() throws Exception {
511         final String[] expected = {
512             "15:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<"),
513             "19:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "<X>"),
514         };
515         verifyWithInlineConfigParser(
516                 getPath("InputJavadocMethod2.java"), expected);
517     }
518 
519     @Test
520     public void test3() throws Exception {
521         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
522         verifyWithInlineConfigParser(
523                 getPath("InputJavadocMethod3.java"), expected);
524     }
525 }