View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2017 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.NonEmptyAtclauseDescriptionCheck.MSG_KEY;
23  import static org.junit.Assert.assertArrayEquals;
24  
25  import org.junit.Test;
26  
27  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28  import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
29  import com.puppycrawl.tools.checkstyle.api.TokenTypes;
30  
31  public class NonEmptyAtclauseDescriptionCheckTest
32          extends AbstractModuleTestSupport {
33      @Override
34      protected String getPackageLocation() {
35          return "com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription";
36      }
37  
38      @Test
39      public void testGetAcceptableTokens() {
40          final NonEmptyAtclauseDescriptionCheck checkObj =
41              new NonEmptyAtclauseDescriptionCheck();
42          final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN};
43          assertArrayEquals("Default acceptable tokens are invalid",
44              expected, checkObj.getAcceptableTokens());
45      }
46  
47      @Test
48      public void testGetRequiredTokens() {
49          final NonEmptyAtclauseDescriptionCheck checkObj =
50              new NonEmptyAtclauseDescriptionCheck();
51          final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN};
52          assertArrayEquals("Default required tokens are invalid",
53              expected, checkObj.getRequiredTokens());
54      }
55  
56      @Test
57      public void testCheck()
58              throws Exception {
59          final DefaultConfiguration checkConfig =
60                  createModuleConfig(NonEmptyAtclauseDescriptionCheck.class);
61          final String[] expected = {
62              //this is a case with description that is sequences of spaces
63              "26: " + getCheckMessage(MSG_KEY),
64              //this is a case with description that is sequences of spaces
65              "27: " + getCheckMessage(MSG_KEY),
66              //this is a case with description that is sequences of spaces
67              "28: " + getCheckMessage(MSG_KEY),
68              //this is a case with description that is sequences of spaces
69              "37: " + getCheckMessage(MSG_KEY),
70              //this is a case with description that is sequences of spaces
71              "38: " + getCheckMessage(MSG_KEY),
72              //this is a case with description that is sequences of spaces
73              "39: " + getCheckMessage(MSG_KEY),
74              "75: " + getCheckMessage(MSG_KEY),
75              "76: " + getCheckMessage(MSG_KEY),
76              "77: " + getCheckMessage(MSG_KEY),
77              "78: " + getCheckMessage(MSG_KEY),
78              "79: " + getCheckMessage(MSG_KEY),
79              "80: " + getCheckMessage(MSG_KEY),
80              "89: " + getCheckMessage(MSG_KEY),
81              "90: " + getCheckMessage(MSG_KEY),
82              "91: " + getCheckMessage(MSG_KEY),
83              "92: " + getCheckMessage(MSG_KEY),
84              "93: " + getCheckMessage(MSG_KEY),
85              "120: " + getCheckMessage(MSG_KEY),
86          };
87          verify(checkConfig, getPath("InputNonEmptyAtclauseDescription.java"), expected);
88      }
89  }