View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2026 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.MissingJavadocMethodCheck.MSG_JAVADOC_MISSING;
24  
25  import java.nio.file.Path;
26  
27  import org.junit.jupiter.api.Test;
28  
29  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
30  import com.puppycrawl.tools.checkstyle.api.DetailAST;
31  import com.puppycrawl.tools.checkstyle.api.TokenTypes;
32  import com.puppycrawl.tools.checkstyle.utils.CheckUtilTest;
33  import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
34  
35  public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport {
36  
37      @Override
38      public String getPackageLocation() {
39          return "com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod";
40      }
41  
42      @Test
43      public void testGetAcceptableTokens() {
44          final MissingJavadocMethodCheck missingJavadocMethodCheck = new MissingJavadocMethodCheck();
45  
46          final int[] actual = missingJavadocMethodCheck.getAcceptableTokens();
47          final int[] expected = {
48              TokenTypes.METHOD_DEF,
49              TokenTypes.CTOR_DEF,
50              TokenTypes.ANNOTATION_FIELD_DEF,
51              TokenTypes.COMPACT_CTOR_DEF,
52          };
53  
54          assertWithMessage("Default acceptable tokens are invalid")
55              .that(actual)
56              .isEqualTo(expected);
57      }
58  
59      @Test
60      public void testGetRequiredTokens() {
61          final MissingJavadocMethodCheck missingJavadocMethodCheck = new MissingJavadocMethodCheck();
62          final int[] actual = missingJavadocMethodCheck.getRequiredTokens();
63          final int[] expected = CommonUtil.EMPTY_INT_ARRAY;
64          assertWithMessage("Required tokens are invalid")
65              .that(actual)
66              .isEqualTo(expected);
67      }
68  
69      @Test
70      public void extendAnnotationTest() throws Exception {
71          final String[] expected = {
72              "44:1: " + getCheckMessage(MSG_JAVADOC_MISSING, "testSetCount_zeroToZero_unsupported"),
73          };
74          verifyWithInlineConfigParser(
75                  getPath("InputMissingJavadocMethodExtendAnnotation.java"), expected);
76      }
77  
78      @Test
79      public void newTest() throws Exception {
80          final String[] expected = {
81              "70:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo7"),
82              "82:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo9"),
83          };
84          verifyWithInlineConfigParser(
85                  getPath("InputMissingJavadocMethodSmallMethods.java"), expected);
86      }
87  
88      @Test
89      public void allowedAnnotationsTest() throws Exception {
90          final String[] expected = {
91              "32:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "allowed3"),
92          };
93          verifyWithInlineConfigParser(
94                  getPath("InputMissingJavadocMethodAllowedAnnotations.java"), expected);
95      }
96  
97      @Test
98      public void testTags1() throws Exception {
99          final String[] expected = {
100             "23:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method1"),
101         };
102         verifyWithInlineConfigParser(
103                 getPath("InputMissingJavadocMethodTags1.java"), expected);
104     }
105 
106     @Test
107     public void testCompactSourceFile() throws Exception {
108         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
109         verifyWithInlineConfigParser(
110                 getNonCompilablePath("InputMissingJavadocMethodCompactSourceFile.java"), expected);
111     }
112 
113     @Test
114     public void testCompactSourceFilePackageScope() throws Exception {
115         final String[] expected = {
116             "23:1: " + getCheckMessage(MSG_JAVADOC_MISSING, "main"),
117         };
118         verifyWithInlineConfigParser(
119                 getNonCompilablePath("InputMissingJavadocMethodCompactSourceFilePackageScope.java"),
120                 expected);
121     }
122 
123     @Test
124     public void testTags2() throws Exception {
125         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
126         verifyWithInlineConfigParser(
127                 getPath("InputMissingJavadocMethodTags2.java"), expected);
128     }
129 
130     @Test
131     public void testTags3() throws Exception {
132         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
133         verifyWithInlineConfigParser(
134                 getPath("InputMissingJavadocMethodTags3.java"), expected);
135     }
136 
137     @Test
138     public void testTags4() throws Exception {
139         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
140         verifyWithInlineConfigParser(
141                 getPath("InputMissingJavadocMethodTags4.java"), expected);
142     }
143 
144     @Test
145     public void testTags5() throws Exception {
146         final String[] expected = {
147             "35:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "someOtherMethod"),
148             "44:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "someField"),
149         };
150         verifyWithInlineConfigParser(
151                 getPath("InputMissingJavadocMethodTags5.java"), expected);
152     }
153 
154     @Test
155     public void testStrictJavadoc() throws Exception {
156         final String[] expected = {
157             "24:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
158             "30:13: " + getCheckMessage(MSG_JAVADOC_MISSING, "InnerInnerClass"),
159             "37:13: " + getCheckMessage(MSG_JAVADOC_MISSING, "method2"),
160             "50:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
161             "60:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly"),
162             "64:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly"),
163             "68:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly"),
164             "73:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly"),
165             "78:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
166             "82:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
167             "86:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
168             "90:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
169         };
170         verifyWithInlineConfigParser(
171                 getPath("InputMissingJavadocMethodPublicOnly.java"), expected);
172     }
173 
174     @Test
175     public void testNoJavadoc() throws Exception {
176         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
177         verifyWithInlineConfigParser(
178                 getPath("InputMissingJavadocMethodPublicOnly2.java"), expected);
179     }
180 
181     // pre 1.4 relaxed mode is roughly equivalent with check=protected
182     @Test
183     public void testRelaxedJavadoc() throws Exception {
184         final String[] expected = {
185             "65:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly3"),
186             "70:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodPublicOnly3"),
187             "83:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
188             "87:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
189         };
190         verifyWithInlineConfigParser(
191                 getPath("InputMissingJavadocMethodPublicOnly3.java"), expected);
192     }
193 
194     @Test
195     public void testScopeInnerInterfacesPublic() throws Exception {
196         final String[] expected = {
197             "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "ma"),
198             "53:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "mb"),
199         };
200         verifyWithInlineConfigParser(
201                 getPath("InputMissingJavadocMethodScopeInnerInterfaces.java"),
202                 expected);
203     }
204 
205     @Test
206     public void testInterfaceMemberScopeIsPublic() throws Exception {
207         final String[] expected = {
208             "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
209             "30:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
210         };
211         verifyWithInlineConfigParser(
212                 getPath("InputMissingJavadocMethodInterfaceMemberScopeIsPublic.java"),
213                 expected);
214     }
215 
216     @Test
217     public void testEnumCtorScopeIsPrivate() throws Exception {
218         final String[] expected = {
219             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "packagePrivateMethod"),
220         };
221         verifyWithInlineConfigParser(
222                 getPath("InputMissingJavadocMethodEnumCtorScopeIsPrivate.java"),
223                 expected);
224     }
225 
226     @Test
227     public void testScopeAnonInnerPrivate() throws Exception {
228         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
229         verifyWithInlineConfigParser(
230                 getPath("InputMissingJavadocMethodScopeAnonInner.java"), expected);
231     }
232 
233     @Test
234     public void testScopeAnonInnerAnonInner() throws Exception {
235         final String[] expected = {
236             "34:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "run"),
237             "47:13: " + getCheckMessage(MSG_JAVADOC_MISSING, "mouseClicked"),
238             "61:13: " + getCheckMessage(MSG_JAVADOC_MISSING, "mouseClicked"), };
239         verifyWithInlineConfigParser(
240                 getPath("InputMissingJavadocMethodScopeAnonInner2.java"), expected);
241     }
242 
243     @Test
244     public void testScopesA() throws Exception {
245         final String[] expected = {
246             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
247             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
248             "28:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
249             "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
250             "37:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
251             "38:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
252             "39:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
253             "40:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
254             "49:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
255             "50:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
256             "51:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
257             "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
258             "61:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
259             "62:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
260             "63:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
261             "64:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
262         };
263         verifyWithInlineConfigParser(
264                 getPath("InputMissingJavadocMethodNoJavadocA.java"), expected);
265     }
266 
267     @Test
268     public void testScopesB() throws Exception {
269         final String[] expected = {
270             "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
271             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
272             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
273             "28:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
274             "36:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
275             "37:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
276             "38:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
277             "39:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
278             "48:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
279             "49:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
280             "50:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
281             "51:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
282             "60:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
283             "61:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
284             "62:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
285             "63:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
286             "72:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
287             "73:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
288             "74:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
289             "75:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
290             "86:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "methodWithTwoStarComment"),
291         };
292         verifyWithInlineConfigParser(
293                 getPath("InputMissingJavadocMethodNoJavadocB.java"), expected);
294     }
295 
296     @Test
297     public void testScopes2A() throws Exception {
298         final String[] expected = {
299             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
300             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
301             "37:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
302             "38:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
303         };
304         verifyWithInlineConfigParser(
305                 getPath("InputMissingJavadocMethodNoJavadoc2A.java"), expected);
306     }
307 
308     @Test
309     public void testScopes2B() throws Exception {
310         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
311         verifyWithInlineConfigParser(
312                 getPath("InputMissingJavadocMethodNoJavadoc2B.java"), expected);
313     }
314 
315     @Test
316     public void testExcludeScopeA() throws Exception {
317         final String[] expected = {
318             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
319             "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
320             "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
321             "50:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
322             "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
323             "53:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
324             "62:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
325             "64:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
326             "65:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
327         };
328         verifyWithInlineConfigParser(
329                 getPath("InputMissingJavadocMethodNoJavadoc3A.java"), expected);
330     }
331 
332     @Test
333     public void testExcludeScopeB() throws Exception {
334         final String[] expected = {
335             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
336             "28:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
337             "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
338             "37:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
339             "39:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
340             "40:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
341             "49:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
342             "51:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
343             "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
344             "61:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
345             "63:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
346             "64:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
347             "73:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
348             "75:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
349             "76:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
350             "87:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "methodWithTwoStarComment"),
351         };
352         verifyWithInlineConfigParser(
353                 getPath("InputMissingJavadocMethodNoJavadoc3B.java"), expected);
354     }
355 
356     @Test
357     public void testDoAllowMissingJavadocTagsByDefault() throws Exception {
358         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
359         verifyWithInlineConfigParser(
360                 getPath("InputMissingJavadocMethodMissingJavadocTags.java"), expected);
361     }
362 
363     @Test
364     public void testSetterGetterOff() throws Exception {
365         final String[] expected = {
366             "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber"),
367             "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNumber"),
368             "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber1"),
369             "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber2"),
370             "41:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNumber2"),
371             "45:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost1"),
372             "50:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost2"),
373             "56:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost3"),
374             "61:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "isSomething"),
375             "66:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "firePropertyChanged"),
376             "68:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setObject"),
377             "72:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNext"),
378             "76:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setWithoutAssignment"),
379             "80:5: " + getCheckMessage(MSG_JAVADOC_MISSING,
380                     "InputMissingJavadocMethodSetterGetter"),
381             "82:5: " + getCheckMessage(MSG_JAVADOC_MISSING,
382                     "InputMissingJavadocMethodSetterGetter"),
383             "88:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setObject"),
384             "90:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getObject"),
385         };
386         verifyWithInlineConfigParser(
387                 getPath("InputMissingJavadocMethodSetterGetter.java"), expected);
388     }
389 
390     @Test
391     public void testSetterGetterOnCheck() throws Exception {
392         final String[] expected = {
393             "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber1"),
394             "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber2"),
395             "41:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNumber2"),
396             "45:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost1"),
397             "50:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost2"),
398             "56:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getCost3"),
399             "66:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "firePropertyChanged"),
400             "68:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setObject"),
401             "72:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNext"),
402             "76:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setWithoutAssignment"),
403             "80:5: " + getCheckMessage(MSG_JAVADOC_MISSING,
404                     "InputMissingJavadocMethodSetterGetter2"),
405             "82:5: " + getCheckMessage(MSG_JAVADOC_MISSING,
406                     "InputMissingJavadocMethodSetterGetter2"),
407             "88:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setObject"),
408             "90:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "getObject"),
409         };
410         verifyWithInlineConfigParser(
411                 getPath("InputMissingJavadocMethodSetterGetter2.java"), expected);
412     }
413 
414     @Test
415     public void test11684081() throws Exception {
416         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
417         verifyWithInlineConfigParser(
418                 getPath("InputMissingJavadocMethod_01.java"), expected);
419     }
420 
421     @Test
422     public void test11684082() throws Exception {
423         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
424         verifyWithInlineConfigParser(
425                 getPath("InputMissingJavadocMethod_02.java"), expected);
426     }
427 
428     @Test
429     public void testSkipCertainMethods() throws Exception {
430         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
431         verifyWithInlineConfigParser(
432                 getPath("InputMissingJavadocMethodIgnoreNameRegex.java"), expected);
433     }
434 
435     @Test
436     public void testNotSkipAnythingWhenSkipRegexDoesNotMatch() throws Exception {
437         final String[] expected = {
438             "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo"),
439             "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo88"),
440             "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
441         };
442         verifyWithInlineConfigParser(
443                 getPath("InputMissingJavadocMethodIgnoreNameRegex2.java"), expected);
444     }
445 
446     @Test
447     public void testAllowToSkipOverridden() throws Exception {
448         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
449         verifyWithInlineConfigParser(
450                 getPath("InputMissingJavadocMethodsNotSkipWritten.java"), expected);
451     }
452 
453     @Test
454     public void testJava8ReceiverParameter() throws Exception {
455         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
456         verifyWithInlineConfigParser(
457                 getPath("InputMissingJavadocMethodReceiverParameter.java"), expected);
458     }
459 
460     @Test
461     public void testJavadocInMethod() throws Exception {
462         final String[] expected = {
463             "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo1"),
464             "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo2"),
465             "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo3"),
466             "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo4"),
467             "31:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo5"),
468             "34:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "foo6"),
469         };
470         verifyWithInlineConfigParser(
471                 getPath("InputMissingJavadocMethodJavadocInMethod.java"), expected);
472     }
473 
474     @Test
475     public void testConstructor() throws Exception {
476         final String[] expected = {
477             "21:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodConstructor"),
478             "23:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "InputMissingJavadocMethodConstructor"),
479         };
480         verifyWithInlineConfigParser(
481                 getPath("InputMissingJavadocMethodConstructor.java"), expected);
482     }
483 
484     @Test
485     public void testNotPublicInterfaceMethods() throws Exception {
486         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
487         verifyWithInlineConfigParser(
488                 getPath("InputMissingJavadocMethodInterfacePrivateMethod.java"), expected);
489     }
490 
491     @Test
492     public void testPublicMethods() throws Exception {
493         final String[] expected = {
494             "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "annotation"),
495             "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "annotationInSignature"),
496             "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "typeInSignature"),
497             "33:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "typeInSignature2"),
498             "38:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "main"),
499         };
500         verifyWithInlineConfigParser(
501                 getPath("InputMissingJavadocMethodPublicMethods.java"), expected);
502 
503     }
504 
505     @Test
506     public void testMissingJavadocMethodRecordsAndCompactCtors() throws Exception {
507         final String[] expected = {
508             "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber"),
509             "27:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "getNumber"),
510             "31:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber1"),
511             "38:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "MySecondRecord"),
512             "44:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "MyThirdRecord"),
513             "48:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "setNumber1"),
514         };
515         verifyWithInlineConfigParser(
516                 getPath("InputMissingJavadocMethodRecordsAndCtors.java"), expected);
517     }
518 
519     @Test
520     public void testMissingJavadocMethodRecordsAndCompactCtorsMinLineCount() throws Exception {
521 
522         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
523 
524         verifyWithInlineConfigParser(
525                 getPath("InputMissingJavadocMethodRecordsAndCtorsMinLineCount.java"),
526             expected);
527     }
528 
529     @Test
530     public void testMinLineCount() throws Exception {
531         final String[] expected = {
532             "14:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "text2Lines"),
533         };
534         verifyWithInlineConfigParser(
535                 getPath("InputMissingJavadocMethod1.java"),
536                 expected);
537     }
538 
539     @Test
540     public void testAnnotationField() throws Exception {
541         final String[] expected = {
542             "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method"),
543             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "value"),
544         };
545 
546         verifyWithInlineConfigParser(
547                 getPath("InputMissingJavadocMethodAnnotationField.java"),
548                 expected);
549     }
550 
551     @Test
552     public void testIsGetterMethod() throws Exception {
553         final Path testFile = Path.of(getPath("InputMissingJavadocMethodSetterGetter3.java"));
554         final DetailAST notGetterMethod = CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF);
555 
556         final DetailAST getterMethod = notGetterMethod.getNextSibling().getNextSibling();
557 
558         assertWithMessage("Invalid result: AST provided is getter method")
559                 .that(MissingJavadocMethodCheck.isGetterMethod(getterMethod))
560                 .isTrue();
561         assertWithMessage("Invalid result: AST provided is not getter method")
562                 .that(MissingJavadocMethodCheck.isGetterMethod(notGetterMethod))
563                 .isFalse();
564     }
565 
566     @Test
567     public void testIsSetterMethod() throws Exception {
568         final Path testFile = Path.of(getPath("InputMissingJavadocMethodSetterGetter3.java"));
569         final DetailAST firstClassMethod = CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF);
570 
571         final DetailAST setterMethod =
572             firstClassMethod.getNextSibling().getNextSibling().getNextSibling();
573         final DetailAST notSetterMethod = setterMethod.getNextSibling();
574 
575         assertWithMessage("Invalid result: AST provided is not setter method")
576                 .that(MissingJavadocMethodCheck.isSetterMethod(setterMethod))
577                 .isTrue();
578         assertWithMessage("Invalid result: AST provided is not setter method")
579                 .that(MissingJavadocMethodCheck.isSetterMethod(notSetterMethod))
580                 .isFalse();
581     }
582 
583     @Test
584     public void testSetterGetterOn() throws Exception {
585         final String[] expected = {
586             "20:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
587                     MSG_JAVADOC_MISSING, "setNumber"),
588             "24:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
589                     MSG_JAVADOC_MISSING, "Cost1"),
590             "29:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
591                     MSG_JAVADOC_MISSING, "getCost1"),
592         };
593         verifyWithInlineConfigParser(
594                 getPath("InputMissingJavadocMethodSetterGetter4.java"), expected);
595     }
596 
597     @Test
598     public void missingJavadoc() throws Exception {
599         final String[] expected = {
600             "15:5: " + getCheckMessage(MissingJavadocMethodCheck.class,
601                     MSG_JAVADOC_MISSING,
602                     "validAssign"),
603         };
604         verifyWithInlineConfigParser(
605                 getPath("InputMissingJavadocMethodBasic.java"), expected);
606     }
607 
608     @Test
609     public void testMissingJavadocMethodAboveComments() throws Exception {
610         final String[] expected = {
611             "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING,
612                     "InputMissingJavadocMethodAboveComments"),
613             "36:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "method2"),
614         };
615         verifyWithInlineConfigParser(
616                 getPath("InputMissingJavadocMethodAboveComments.java"),
617                 expected);
618     }
619 
620     @Test
621     public void testNewCasesAfterAstMigration() throws Exception {
622         final String[] expected = {
623             "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "annotatedSingleLineMethod"),
624             "31:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "annotatedBenchmarkMethod"),
625             "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "annotatedMethodWithAnnotationValue"),
626             "39:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "map"),
627             "47:9: " + getCheckMessage(MSG_JAVADOC_MISSING, "Includes"),
628             "68:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "oneLineStaticMethod"),
629             "71:5: " + getCheckMessage(MSG_JAVADOC_MISSING, "get"),
630         };
631         verifyWithInlineConfigParser(
632                 getPath("InputMissingJavadocMethodNewCasesAfterAstMigration.java"), expected);
633     }
634 
635 }