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.AbstractJavadocCheck.MSG_KEY_UNCLOSED_HTML_TAG;
24 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_MISSING_TAG;
25 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_MISSING_TAG_WITH_QUOTES;
26 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_TAG_FORMAT;
27 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_UNKNOWN_TAG;
28 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_UNUSED_TAG;
29 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_UNUSED_TAG_GENERAL;
30
31 import org.junit.jupiter.api.Test;
32
33 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
34 import com.puppycrawl.tools.checkstyle.api.JavadocCommentsTokenTypes;
35 import com.puppycrawl.tools.checkstyle.api.TokenTypes;
36 import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
37 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
38
39 public class JavadocTypeCheckTest extends AbstractModuleTestSupport {
40
41 @Override
42 public String getPackageLocation() {
43 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctype";
44 }
45
46 @Test
47 public void testGetRequiredTokens() {
48 final JavadocTypeCheck javadocTypeCheck = new JavadocTypeCheck();
49 assertWithMessage("JavadocTypeCheck#getRequiredTokens should return empty array by default")
50 .that(javadocTypeCheck.getRequiredTokens())
51 .isEqualTo(CommonUtil.EMPTY_INT_ARRAY);
52 }
53
54 @Test
55 public void testGetAcceptableTokens() {
56 final JavadocTypeCheck javadocTypeCheck = new JavadocTypeCheck();
57
58 final int[] actual = javadocTypeCheck.getAcceptableTokens();
59 final int[] expected = {
60 TokenTypes.INTERFACE_DEF,
61 TokenTypes.CLASS_DEF,
62 TokenTypes.ENUM_DEF,
63 TokenTypes.ANNOTATION_DEF,
64 TokenTypes.RECORD_DEF,
65 };
66
67 assertWithMessage("Default acceptable tokens are invalid")
68 .that(actual)
69 .isEqualTo(expected);
70 }
71
72 @Test
73 public void testTags1() throws Exception {
74 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
75 verifyWithInlineConfigParser(
76 getPath("InputJavadocTypeTags1.java"), expected);
77 }
78
79 @Test
80 public void testTags2() throws Exception {
81 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
82 verifyWithInlineConfigParser(
83 getPath("InputJavadocTypeTags2.java"), expected);
84 }
85
86 @Test
87 public void testTags3() throws Exception {
88 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
89 verifyWithInlineConfigParser(
90 getPath("InputJavadocTypeTags3.java"), expected);
91 }
92
93 @Test
94 public void testTags4() throws Exception {
95 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
96 verifyWithInlineConfigParser(
97 getPath("InputJavadocTypeTags4.java"), expected);
98 }
99
100 @Test
101 public void testInner() throws Exception {
102 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
103 verifyWithInlineConfigParser(
104 getPath("InputJavadocTypeInner.java"), expected);
105 }
106
107 @Test
108 public void testStrict() throws Exception {
109 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
110 verifyWithInlineConfigParser(
111 getPath("InputJavadocTypePublicOnly.java"), expected);
112 }
113
114 @Test
115 public void testProtected() throws Exception {
116 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
117 verifyWithInlineConfigParser(
118 getPath("InputJavadocTypePublicOnly1.java"), expected);
119 }
120
121 @Test
122 public void testProtectedTwo() throws Exception {
123 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
124 verifyWithInlineConfigParser(
125 getPath("InputJavadocTypePublicOnly1Two.java"), expected);
126 }
127
128 @Test
129 public void testPublic() throws Exception {
130 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
131 verifyWithInlineConfigParser(
132 getPath("InputJavadocTypeScopeInnerInterfaces.java"),
133 expected);
134 }
135
136 @Test
137 public void testProtest() throws Exception {
138 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
139 verifyWithInlineConfigParser(
140 getPath("InputJavadocTypeScopeInnerInterfaces1.java"),
141 expected);
142 }
143
144 @Test
145 public void testPkg() throws Exception {
146 final String[] expected = {
147 "53:5: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
148 };
149 verifyWithInlineConfigParser(
150 getPath("InputJavadocTypeScopeInnerClasses.java"), expected);
151 }
152
153 @Test
154 public void testEclipse() throws Exception {
155 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
156 verifyWithInlineConfigParser(
157 getPath("InputJavadocTypeScopeInnerClasses1.java"), expected);
158 }
159
160 @Test
161 public void testAuthorRequired() throws Exception {
162 final String[] expected = {
163 "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
164 };
165 verifyWithInlineConfigParser(
166 getPath("InputJavadocTypeWhitespace.java"), expected);
167 }
168
169 @Test
170 public void testAuthorRegularEx()
171 throws Exception {
172 final String[] expected = {
173 "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
174 "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
175 "103:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
176 };
177 verifyWithInlineConfigParser(
178 getPath("InputJavadocTypeJavadoc.java"), expected);
179 }
180
181 @Test
182 public void testAuthorRegularExError()
183 throws Exception {
184 final String[] expected = {
185 "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
186 "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
187 "40:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
188 "64:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
189 "73:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
190 "82:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
191 "100:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
192 "109:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
193 "118:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
194 "135:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
195 };
196 verifyWithInlineConfigParser(
197 getPath("InputJavadocTypeJavadoc_1.java"), expected);
198 }
199
200 @Test
201 public void testVersionRequired()
202 throws Exception {
203 final String[] expected = {
204 "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
205 };
206 verifyWithInlineConfigParser(
207 getPath("InputJavadocTypeWhitespace_1.java"), expected);
208 }
209
210 @Test
211 public void testVersionRegularEx()
212 throws Exception {
213 final String[] expected = {
214 "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
215 "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
216 "103:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
217 };
218 verifyWithInlineConfigParser(
219 getPath("InputJavadocTypeJavadoc_3.java"), expected);
220 }
221
222 @Test
223 public void testAstParamAndVersionBranches() throws Exception {
224 final String[] expected = {
225 "20:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
226 };
227 verifyWithInlineConfigParser(
228 getPath("InputJavadocTypeAstCoverage.java"), expected);
229 }
230
231 @Test
232 public void testVersionRegularExError()
233 throws Exception {
234 final String[] expected = {
235 "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
236 "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
237 "40:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
238 "49:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
239 "58:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
240 "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
241 "76:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
242 "85:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
243 "94:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
244 "103:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"),
245 "112:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
246 "121:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"),
247 };
248 verifyWithInlineConfigParser(
249 getPath("InputJavadocTypeJavadoc_2.java"), expected);
250 }
251
252 @Test
253 public void testScopes() throws Exception {
254 final String[] expected = {
255 "18:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
256 "137:5: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
257 };
258 verifyWithInlineConfigParser(
259 getPath("InputJavadocTypeNoJavadoc.java"),
260 expected);
261 }
262
263 @Test
264 public void testLimitViolationsBySpecifyingTokens() throws Exception {
265 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
266 verifyWithInlineConfigParser(
267 getPath("InputJavadocTypeNoJavadocOnInterface.java"),
268 expected);
269 }
270
271 @Test
272 public void testScopes2() throws Exception {
273 final String[] expected = {
274 "18:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
275 };
276 verifyWithInlineConfigParser(
277 getPath("InputJavadocTypeNoJavadoc_2.java"),
278 expected);
279 }
280
281 @Test
282 public void testExcludeScope() throws Exception {
283 final String[] expected = {
284 "137:5: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
285 };
286 verifyWithInlineConfigParser(
287 getPath("InputJavadocTypeNoJavadoc_1.java"),
288 expected);
289 }
290
291 @Test
292 public void testTypeParameters() throws Exception {
293 final String[] expected = {
294 "22:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<D123>"),
295 "26:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<C456>"),
296 "61:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<C>"),
297 "64:5: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<B>"),
298 "69:5: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "x"),
299 "73:5: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL, "@param"),
300 };
301 verifyWithInlineConfigParser(
302 getPath("InputJavadocTypeTypeParamsTags_1.java"), expected);
303 }
304
305 @Test
306 public void testAllowMissingTypeParameters() throws Exception {
307 final String[] expected = {
308 "22:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<D123>"),
309 "60:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<C>"),
310 "68:5: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "x"),
311 };
312 verifyWithInlineConfigParser(
313 getPath("InputJavadocTypeTypeParamsTags.java"), expected);
314 }
315
316 @Test
317 public void testDontAllowUnusedParameterTag() throws Exception {
318 final String[] expected = {
319 "22:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"),
320 "23:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<BAD>"),
321 };
322 verifyWithInlineConfigParser(
323 getPath("InputJavadocTypeUnusedParamInJavadocForClass.java"),
324 expected);
325 }
326
327 @Test
328 public void testBadTag() throws Exception {
329 final String[] expected = {
330 "21:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "mytag"),
331 "22:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "mytag"),
332 "29:5: " + getCheckMessage(MSG_UNKNOWN_TAG, "mytag"),
333 };
334 verifyWithInlineConfigParser(
335 getPath("InputJavadocTypeBadTag.java"),
336 expected);
337 }
338
339 @Test
340 public void testBadTagSuppress() throws Exception {
341 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
342 verifyWithInlineConfigParser(
343 getPath("InputJavadocTypeBadTag_1.java"),
344 expected);
345 }
346
347 @Test
348 public void testAllowedAnnotationsDefault() throws Exception {
349
350 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
351 verifyWithInlineConfigParser(
352 getPath("InputJavadocTypeAllowedAnnotations.java"),
353 expected);
354 }
355
356 @Test
357 public void testAllowedAnnotationsWithFullyQualifiedName() throws Exception {
358 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
359 verifyWithInlineConfigParser(
360 getPath("InputJavadocTypeAllowedAnnotations_1.java"),
361 expected);
362 }
363
364 @Test
365 public void testAllowedAnnotationsAllowed() throws Exception {
366
367 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
368 verifyWithInlineConfigParser(
369 getPath("InputJavadocTypeAllowedAnnotations_2.java"),
370 expected);
371 }
372
373 @Test
374 public void testAllowedAnnotationsNotAllowed() throws Exception {
375
376 final String[] expected = {
377 "38:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
378 };
379 verifyWithInlineConfigParser(
380 getPath("InputJavadocTypeAllowedAnnotations_3.java"),
381 expected);
382 }
383
384 @Test
385 public void testJavadocTypeRecords() throws Exception {
386 final String[] expected = {
387 "24:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
388 "33:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
389 "42:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
390 "55:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"),
391 "65:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
392 };
393 verifyWithInlineConfigParser(
394 getPath("InputJavadocTypeRecords.java"), expected);
395 }
396
397 @Test
398 public void testJavadocTypeRecordComponents() throws Exception {
399
400 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
401
402 verifyWithInlineConfigParser(
403 getPath("InputJavadocTypeRecordComponents.java"), expected);
404 }
405
406 @Test
407 public void testJavadocTypeRecordComponentNameMismatch() throws Exception {
408 final String[] expected1 = {
409 "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "valueExtra"),
410 "23:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "value"),
411 };
412 verifyWithInlineConfigParser(
413 getPath("InputJavadocTypeRecordComponentNameMismatch.java"), expected1);
414 }
415
416 @Test
417 public void testJavadocTypeParamDescriptionWithAngularTags() throws Exception {
418 final String[] expected = {
419 "53:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<P>"),
420 "55:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<U>"),
421 "60:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "region"),
422 };
423
424 verifyWithInlineConfigParser(
425 getPath("InputJavadocTypeParamDescriptionWithAngularTags.java"), expected);
426 }
427
428 @Test
429 public void testJavadocTypeRecordParamDescriptionWithAngularTags() throws Exception {
430 final String[] expected = {
431 "60:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<P>"),
432 "62:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<U>"),
433 "67:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "region"),
434 "69:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "a"),
435 "83:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "e"),
436 "85:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "c"),
437 };
438
439 verifyWithInlineConfigParser(
440 getPath(
441 "InputJavadocTypeRecordParamDescriptionWithAngularTags.java"),
442 expected);
443 }
444
445 @Test
446 public void testJavadocTypeRecordComponents2() throws Exception {
447
448 final String[] expected = {
449 "44:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<X>"),
450 "49:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "x"),
451 "61:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "notMyString"),
452 "64:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "myString"),
453 "64:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "myInt"),
454 "69:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "x"),
455 "71:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "myList"),
456 "78:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "X"),
457 "82:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "notMyString"),
458 "85:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "<T>"),
459 "85:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "myInt"),
460 "85:1: " + getCheckMessage(MSG_MISSING_TAG_WITH_QUOTES, "@param", "myString"),
461 };
462 verifyWithInlineConfigParser(
463 getPath("InputJavadocTypeRecordComponents2.java"), expected);
464 }
465
466 @Test
467 public void testJavadocTypeInterfaceMemberScopeIsPublic() throws Exception {
468
469 final String[] expected = {
470 "19:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<T>"),
471 "24:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<T>"),
472 };
473 verifyWithInlineConfigParser(
474 getPath("InputJavadocTypeInterfaceMemberScopeIsPublic.java"), expected);
475 }
476
477 @Test
478 public void testAuthorFormat() throws Exception {
479 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
480 verifyWithInlineConfigParser(
481 getPath("InputJavadocType1.java"), expected);
482 }
483
484 @Test
485 public void testAuthorFormat2() throws Exception {
486 final String[] expected = {
487 "21:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
488 };
489 verifyWithInlineConfigParser(
490 getPath("InputJavadocType2.java"), expected);
491 }
492
493 @Test
494 public void testJavadocType2() throws Exception {
495 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
496 verifyWithInlineConfigParser(
497 getPath("InputJavadocType4.java"), expected);
498 }
499
500 @Test
501 public void testJavadocTypeAboveComments() throws Exception {
502 final String[] expected = {
503 "22:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
504 "48:15: " + getCheckMessage(MSG_MISSING_TAG, "@author"),
505 };
506 verifyWithInlineConfigParser(
507 getPath("InputJavadocTypeAboveComments.java"), expected);
508 }
509
510 @Test
511 public void testJavadocWithNative() throws Exception {
512 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
513 verifyWithInlineConfigParser(
514 getPath("InputJavadocTypeWithNative.java"), expected);
515 }
516
517 @Test
518 public void testJavadocTypeWithBlockComment() throws Exception {
519 final String[] expected = {
520 "21:5: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<T>"),
521 };
522 verifyWithInlineConfigParser(
523 getPath("InputJavadocTypeWithBlockComment.java"), expected);
524 }
525
526 @Test
527 public void testAnnotationsInCodeBlock() throws Exception {
528 final String[] expected = {
529 "99:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
530 "106:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
531 };
532 verifyWithInlineConfigParser(
533 getPath("InputJavadocTypeAnnotationsInCodeBlock.java"), expected);
534 }
535
536 @Test
537 public void testAnnotationsInCodeBlock2() throws Exception {
538 final String[] expected = {
539 "35:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
540 "49:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
541 "57:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
542 };
543 verifyWithInlineConfigParser(
544 getPath("InputJavadocTypeAnnotationsInCodeBlock2.java"), expected);
545 }
546
547 @Test
548 public void testAnnotationsInCodeBlock3() throws Exception {
549 final String[] expected = {
550 "32:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
551 "78:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
552 "86:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
553 "94:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
554 };
555 verifyWithInlineConfigParser(
556 getPath("InputJavadocTypeAnnotationsInCodeBlock3.java"), expected);
557 }
558
559 @Test
560 public void testAnnotationsInCodeBlock4() throws Exception {
561 final String[] expected = {
562 "29:5: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
563 "42:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
564 "50:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
565 "58:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "unknown"),
566 };
567 verifyWithInlineConfigParser(
568 getPath("InputJavadocTypeAnnotationsInCodeBlock4.java"), expected);
569 }
570
571 @Test
572 public void testJavadocTypeHtml() throws Exception {
573 final String[] expected = {
574 "19: " + getCheckMessage(MSG_KEY_UNCLOSED_HTML_TAG, "p"),
575 };
576 verifyWithInlineConfigParser(
577 getPath("InputJavadocTypeHtml.java"), expected);
578
579 }
580
581
582
583
584
585
586
587 @Test
588 public void testImproperJavadocToken() {
589 final JavadocTypeCheck check = new JavadocTypeCheck();
590
591 final JavadocNodeImpl ast = new JavadocNodeImpl();
592 ast.setType(JavadocCommentsTokenTypes.EQUALS);
593 ast.setText("EQUALS");
594
595 final IllegalArgumentException exc = TestUtil.getExpectedThrowable(
596 IllegalArgumentException.class,
597 () -> check.visitJavadocToken(ast));
598
599 assertWithMessage("Message must include token name")
600 .that(exc.getMessage())
601 .contains("EQUALS");
602 }
603
604 }