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.SingleLineJavadocCheck.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
30 public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport {
31
32 @Override
33 protected String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/javadoc/singlelinejavadoc";
35 }
36
37 @Test
38 public void testAcceptableTokens() {
39 final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck();
40 final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
41 assertWithMessage("Default acceptable tokens are invalid")
42 .that(checkObj.getAcceptableTokens())
43 .isEqualTo(expected);
44 }
45
46 @Test
47 public void testGetRequiredTokens() {
48 final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck();
49 final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN };
50 assertWithMessage("Default required tokens are invalid")
51 .that(checkObj.getRequiredTokens())
52 .isEqualTo(expected);
53 }
54
55 @Test
56 public void simpleTest() throws Exception {
57 final String[] expected = {
58 "22: " + getCheckMessage(MSG_KEY),
59 "38: " + getCheckMessage(MSG_KEY),
60 "50: " + getCheckMessage(MSG_KEY),
61 "53: " + getCheckMessage(MSG_KEY),
62 "59: " + getCheckMessage(MSG_KEY),
63 };
64 verifyWithInlineConfigParser(
65 getPath("InputSingleLineJavadoc.java"), expected);
66 }
67
68 @Test
69 public void testIgnoredTags() throws Exception {
70 final String[] expected = {
71 "14: " + getCheckMessage(MSG_KEY),
72 "44: " + getCheckMessage(MSG_KEY),
73 "47: " + getCheckMessage(MSG_KEY),
74 "50: " + getCheckMessage(MSG_KEY),
75 "56: " + getCheckMessage(MSG_KEY),
76 "59: " + getCheckMessage(MSG_KEY),
77 };
78 verifyWithInlineConfigParser(
79 getPath("InputSingleLineJavadocIgnoredTags.java"), expected);
80 }
81
82 }