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.JavadocMissingWhitespaceAfterAsteriskCheck.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.JavadocTokenTypes;
29 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
30
31 public class JavadocMissingWhitespaceAfterAsteriskCheckTest
32 extends AbstractModuleTestSupport {
33
34 @Override
35 protected String getPackageLocation() {
36 return "com/puppycrawl/tools/checkstyle/checks/javadoc"
37 + "/javadocmissingwhitespaceafterasterisk";
38 }
39
40 @Test
41 public void testGetAcceptableTokens() {
42 final JavadocMissingWhitespaceAfterAsteriskCheck checkObj =
43 new JavadocMissingWhitespaceAfterAsteriskCheck();
44 final int[] expected = {
45 JavadocTokenTypes.JAVADOC,
46 JavadocTokenTypes.LEADING_ASTERISK,
47 };
48 assertWithMessage("Default tokens are invalid")
49 .that(checkObj.getAcceptableJavadocTokens())
50 .isEqualTo(expected);
51 }
52
53 @Test
54 public void testGetRequiredJavadocTokens() {
55 final JavadocMissingWhitespaceAfterAsteriskCheck checkObj =
56 new JavadocMissingWhitespaceAfterAsteriskCheck();
57 final int[] expected = {
58 JavadocTokenTypes.JAVADOC,
59 JavadocTokenTypes.LEADING_ASTERISK,
60 };
61 assertWithMessage("Default required tokens are invalid")
62 .that(checkObj.getRequiredJavadocTokens())
63 .isEqualTo(expected);
64 }
65
66 @Test
67 public void testValid() throws Exception {
68 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
69
70 verifyWithInlineConfigParser(
71 getPath("InputJavadocMissingWhitespaceAfterAsteriskValid.java"), expected);
72 }
73
74 @Test
75 public void testValidWithTabCharacter() throws Exception {
76 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
77
78 verifyWithInlineConfigParser(
79 getPath("InputJavadocMissingWhitespaceAfterAsteriskValidWithTab.java"), expected);
80 }
81
82 @Test
83 public void testInvalid() throws Exception {
84 final String[] expected = {
85 "10:4: " + getCheckMessage(MSG_KEY),
86 "16:7: " + getCheckMessage(MSG_KEY),
87 "21:11: " + getCheckMessage(MSG_KEY),
88 "28:11: " + getCheckMessage(MSG_KEY),
89 "32:13: " + getCheckMessage(MSG_KEY),
90 "38:7: " + getCheckMessage(MSG_KEY),
91 "43:7: " + getCheckMessage(MSG_KEY),
92 "48:7: " + getCheckMessage(MSG_KEY),
93 "53:7: " + getCheckMessage(MSG_KEY),
94 "55:7: " + getCheckMessage(MSG_KEY),
95 "59:8: " + getCheckMessage(MSG_KEY),
96 "62:8: " + getCheckMessage(MSG_KEY),
97 "65:10: " + getCheckMessage(MSG_KEY),
98 };
99 verifyWithInlineConfigParser(
100 getPath("InputJavadocMissingWhitespaceAfterAsteriskInvalid.java"), expected);
101 }
102
103 }