1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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.JavadocTagContinuationIndentationCheck.MSG_KEY;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28 import com.puppycrawl.tools.checkstyle.api.TokenTypes;
29 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
30
31 public class JavadocTagContinuationIndentationCheckTest
32 extends AbstractModuleTestSupport {
33
34 @Override
35 protected String getPackageLocation() {
36 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation";
37 }
38
39 @Test
40 public void testGetRequiredTokens() {
41 final JavadocTagContinuationIndentationCheck checkObj =
42 new JavadocTagContinuationIndentationCheck();
43 final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
44 assertWithMessage("Default required tokens are invalid")
45 .that(checkObj.getRequiredTokens())
46 .isEqualTo(expected);
47 }
48
49 @Test
50 public void testFp() throws Exception {
51 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
52 verifyWithInlineConfigParser(
53 getPath("InputJavadocTagContinuationIndentationGuavaFalsePositive.java"),
54 expected);
55 }
56
57 @Test
58 public void testCheck() throws Exception {
59 final String[] expected = {
60 "55: " + getCheckMessage(MSG_KEY, 4),
61 "117: " + getCheckMessage(MSG_KEY, 4),
62 "120: " + getCheckMessage(MSG_KEY, 4),
63 "211: " + getCheckMessage(MSG_KEY, 4),
64 "214: " + getCheckMessage(MSG_KEY, 4),
65 "229: " + getCheckMessage(MSG_KEY, 4),
66 "231: " + getCheckMessage(MSG_KEY, 4),
67 "293: " + getCheckMessage(MSG_KEY, 4),
68 "296: " + getCheckMessage(MSG_KEY, 4),
69 "298: " + getCheckMessage(MSG_KEY, 4),
70 "318: " + getCheckMessage(MSG_KEY, 4),
71 "330: " + getCheckMessage(MSG_KEY, 4),
72 "332: " + getCheckMessage(MSG_KEY, 4),
73 "350: " + getCheckMessage(MSG_KEY, 4),
74 };
75 verifyWithInlineConfigParser(
76 getPath("InputJavadocTagContinuationIndentation.java"),
77 expected);
78 }
79
80 @Test
81 public void testCheckWithOffset3() throws Exception {
82 final String[] expected = {
83 "15: " + getCheckMessage(MSG_KEY, 3),
84 "27: " + getCheckMessage(MSG_KEY, 3),
85 };
86 verifyWithInlineConfigParser(
87 getPath("InputJavadocTagContinuationIndentationOffset3.java"),
88 expected);
89 }
90
91 @Test
92 public void testCheckWithDescription() throws Exception {
93 final String[] expected = {
94 "16: " + getCheckMessage(MSG_KEY, 4),
95 "17: " + getCheckMessage(MSG_KEY, 4),
96 "18: " + getCheckMessage(MSG_KEY, 4),
97 "47: " + getCheckMessage(MSG_KEY, 4),
98 "49: " + getCheckMessage(MSG_KEY, 4),
99 "50: " + getCheckMessage(MSG_KEY, 4),
100 };
101 verifyWithInlineConfigParser(
102 getPath("InputJavadocTagContinuationIndentationDescription.java"),
103 expected);
104 }
105
106 @Test
107 public void testBlockTag() throws Exception {
108 final String[] expected = {
109 "21: " + getCheckMessage(MSG_KEY, 4),
110 "32: " + getCheckMessage(MSG_KEY, 4),
111 "42: " + getCheckMessage(MSG_KEY, 4),
112 "62: " + getCheckMessage(MSG_KEY, 4),
113 "64: " + getCheckMessage(MSG_KEY, 4),
114 "74: " + getCheckMessage(MSG_KEY, 4),
115 "75: " + getCheckMessage(MSG_KEY, 4),
116 "76: " + getCheckMessage(MSG_KEY, 4),
117 "86: " + getCheckMessage(MSG_KEY, 4),
118 "87: " + getCheckMessage(MSG_KEY, 4),
119 "88: " + getCheckMessage(MSG_KEY, 4),
120 "89: " + getCheckMessage(MSG_KEY, 4),
121 "90: " + getCheckMessage(MSG_KEY, 4),
122 "91: " + getCheckMessage(MSG_KEY, 4),
123 "92: " + getCheckMessage(MSG_KEY, 4),
124 "93: " + getCheckMessage(MSG_KEY, 4),
125 "94: " + getCheckMessage(MSG_KEY, 4),
126 "95: " + getCheckMessage(MSG_KEY, 4),
127 "96: " + getCheckMessage(MSG_KEY, 4),
128 "97: " + getCheckMessage(MSG_KEY, 4),
129 "98: " + getCheckMessage(MSG_KEY, 4),
130 "99: " + getCheckMessage(MSG_KEY, 4),
131 "104: " + getCheckMessage(MSG_KEY, 4),
132 "105: " + getCheckMessage(MSG_KEY, 4),
133 };
134 verifyWithInlineConfigParser(
135 getPath("InputJavadocTagContinuationIndentationBlockTag.java"),
136 expected);
137 }
138
139 @Test
140 public void testContinuationIndentation() throws Exception {
141 final String[] expected = {
142 "23: " + getCheckMessage(MSG_KEY, 4),
143 };
144 verifyWithInlineConfigParser(
145 getPath("InputJavadocTagContinuationIndentation1.java"),
146 expected);
147 }
148
149 @Test
150 public void testJavadocTagContinuationIndentationCheck1() throws Exception {
151 final String[] expected = {
152 "16: " + getCheckMessage(MSG_KEY, 4),
153 };
154 verifyWithInlineConfigParser(
155 getPath("InputJavadocTagContinuationIndentationCheck1.java"),
156 expected);
157 }
158
159 @Test
160 public void testJavadocTagContinuationIndentationCheckHtml() throws Exception {
161 final String[] expected = {
162 "15: " + getCheckMessage(MSG_KEY, 4),
163 "18: " + getCheckMessage(MSG_KEY, 4),
164 "28: " + getCheckMessage(MSG_KEY, 4),
165 "29: " + getCheckMessage(MSG_KEY, 4),
166 "30: " + getCheckMessage(MSG_KEY, 4),
167 "50: " + getCheckMessage(MSG_KEY, 4),
168 "51: " + getCheckMessage(MSG_KEY, 4),
169 "52: " + getCheckMessage(MSG_KEY, 4),
170 "63: " + getCheckMessage(MSG_KEY, 4),
171 "64: " + getCheckMessage(MSG_KEY, 4),
172 "65: " + getCheckMessage(MSG_KEY, 4),
173 "75: " + getCheckMessage(MSG_KEY, 4),
174 "76: " + getCheckMessage(MSG_KEY, 4),
175 };
176 verifyWithInlineConfigParser(
177 getPath("InputJavadocTagContinuationIndentationCheckHtml.java"),
178 expected);
179 }
180 }