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