View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2025 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.JavadocTypeCheck.MSG_MISSING_TAG;
23  import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_UNKNOWN_TAG;
24  
25  import org.junit.jupiter.api.Test;
26  
27  import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
28  
29  public class JavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport {
30      @Override
31      protected String getPackageLocation() {
32          return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctype";
33      }
34  
35      @Test
36      public void testExample1() throws Exception {
37          final String[] expected = {
38              "28:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
39              "36:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
40              "39:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
41          };
42  
43          verifyWithInlineConfigParser(getPath("Example1.java"), expected);
44      }
45  
46      @Test
47      public void testExample2() throws Exception {
48          final String[] expected = {
49              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
50              "38:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
51          };
52  
53          verifyWithInlineConfigParser(getPath("Example2.java"), expected);
54      }
55  
56      @Test
57      public void testExample3() throws Exception {
58          final String[] expected = {
59              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
60              "38:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
61              "41:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
62          };
63  
64          verifyWithInlineConfigParser(getPath("Example3.java"), expected);
65      }
66  
67      @Test
68      public void testExample4() throws Exception {
69          final String[] expected = {
70              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
71              "38:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
72              "41:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
73  
74          };
75  
76          verifyWithInlineConfigParser(getPath("Example4.java"), expected);
77      }
78  
79      @Test
80      public void testExample5() throws Exception {
81          final String[] expected = {
82              "42:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
83          };
84  
85          verifyWithInlineConfigParser(getPath("Example5.java"), expected);
86      }
87  
88      @Test
89      public void testExample6() throws Exception {
90          final String[] expected = {
91              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
92          };
93  
94          verifyWithInlineConfigParser(getPath("Example6.java"), expected);
95      }
96  
97      @Test
98      public void testExample7() throws Exception {
99          final String[] expected = {
100             "38:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
101             "41:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
102         };
103 
104         verifyWithInlineConfigParser(getPath("Example7.java"), expected);
105     }
106 
107     @Test
108     public void testExample8() throws Exception {
109         final String[] expected = {
110             "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
111             "38:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
112             "41:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
113             "44:3: " + getCheckMessage(MSG_MISSING_TAG, "@param <T>"),
114         };
115 
116         verifyWithInlineConfigParser(getPath("Example8.java"), expected);
117     }
118 }