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.JavadocBlockTagLocationCheck.MSG_BLOCK_TAG_LOCATION;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28 import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes;
29 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
30
31 public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport {
32
33 @Override
34 protected String getPackageLocation() {
35 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocblocktaglocation";
36 }
37
38 @Test
39 public void testGetAcceptableTokens() {
40 final JavadocBlockTagLocationCheck checkObj = new JavadocBlockTagLocationCheck();
41 final int[] expected = {
42 JavadocTokenTypes.TEXT,
43 };
44 assertWithMessage("Default acceptable tokens are invalid")
45 .that(checkObj.getAcceptableJavadocTokens())
46 .isEqualTo(expected);
47 }
48
49 @Test
50 public void testCorrect() throws Exception {
51 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
52
53 verifyWithInlineConfigParser(
54 getPath("InputJavadocBlockTagLocationCorrect.java"), expected);
55 }
56
57
58
59
60
61
62
63
64
65
66 @Test
67 public void testMultilineCodeBlock() throws Exception {
68 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
69
70 verifyWithInlineConfigParser(
71 getPath("InputJavadocBlockTagLocationMultilineCodeBlock.java"), expected);
72 }
73
74 @Test
75 public void testIncorrect() throws Exception {
76 final String[] expected = {
77 "15: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "author"),
78 "16: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "since"),
79 "17: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "param"),
80 "19: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "throws"),
81 "20: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "see"),
82 "21: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "return"),
83 "21: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "throws"),
84 };
85 verifyWithInlineConfigParser(
86 getPath("InputJavadocBlockTagLocationIncorrect.java"), expected);
87 }
88
89 @Test
90 public void testCustomTags() throws Exception {
91 final String[] expected = {
92 "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "apiNote"),
93 "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implNote"),
94 "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implSpec"),
95 "16: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "apiNote"),
96 "17: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implNote"),
97 "18: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implSpec"),
98 };
99 verifyWithInlineConfigParser(
100 getPath("InputJavadocBlockTagLocationCustomTags.java"), expected);
101 }
102
103 }