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.JavadocTypeCheck.MSG_MISSING_TAG_WITH_QUOTES;
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  
31      @Override
32      public String getPackageLocation() {
33          return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctype";
34      }
35  
36      @Test
37      public void testExample1() throws Exception {
38          final String[] expected = {
39              "28:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
40              "36:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
41              "39:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
42          };
43  
44          verifyWithInlineConfigParser(getPath("Example1.java"), expected);
45      }
46  
47      @Test
48      public void testExample2() throws Exception {
49          final String[] expected = {
50              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
51              "38:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
52          };
53  
54          verifyWithInlineConfigParser(getPath("Example2.java"), expected);
55      }
56  
57      @Test
58      public void testExample3() throws Exception {
59          final String[] expected = {
60              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
61              "38:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
62              "41:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
63          };
64  
65          verifyWithInlineConfigParser(getPath("Example3.java"), expected);
66      }
67  
68      @Test
69      public void testExample4() throws Exception {
70          final String[] expected = {
71              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
72              "38:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
73              "41:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
74  
75          };
76  
77          verifyWithInlineConfigParser(getPath("Example4.java"), expected);
78      }
79  
80      @Test
81      public void testExample5() throws Exception {
82          final String[] expected = {
83              "42:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
84          };
85  
86          verifyWithInlineConfigParser(getPath("Example5.java"), expected);
87      }
88  
89      @Test
90      public void testExample6() throws Exception {
91          final String[] expected = {
92              "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
93          };
94  
95          verifyWithInlineConfigParser(getPath("Example6.java"), expected);
96      }
97  
98      @Test
99      public void testExample7() throws Exception {
100         final String[] expected = {
101             "38:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
102             "41:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
103         };
104 
105         verifyWithInlineConfigParser(getPath("Example7.java"), expected);
106     }
107 
108     @Test
109     public void testExample8() throws Exception {
110         final String[] expected = {
111             "30:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
112             "38:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
113             "41:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
114             "44:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
115         };
116 
117         verifyWithInlineConfigParser(getPath("Example8.java"), expected);
118     }
119 
120     @Test
121     public void testExample9() throws Exception {
122         final String[] expected = {
123             "31:6: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknownTag"),
124             "39:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
125             "42:3: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
126         };
127 
128         verifyWithInlineConfigParser(getPath("Example9.java"), expected);
129     }
130 
131 }