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.annotation;
21
22 import org.junit.jupiter.api.Test;
23
24 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
25 import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck;
26 import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck;
27 import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
28 import com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck;
29 import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck;
30
31 public class SuppressWarningsHolderExamplesTest extends AbstractExamplesModuleTestSupport {
32 @Override
33 protected String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder";
35 }
36
37 @Test
38 public void testExample1() throws Exception {
39 final String pattern1 = "^[a-z][a-zA-Z0-9]*$";
40 final String pattern2 = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$";
41 final String[] expected = {
42 "20:15: " + getCheckMessage(MemberNameCheck.class,
43 AbstractNameCheck.MSG_INVALID_PATTERN, "K", pattern1),
44 "24:28: " + getCheckMessage(ConstantNameCheck.class,
45 AbstractNameCheck.MSG_INVALID_PATTERN, "i", pattern2),
46 "34:15: " + getCheckMessage(NoWhitespaceAfterCheck.class,
47 NoWhitespaceAfterCheck.MSG_KEY, "int"),
48 "34:18: " + getCheckMessage(MemberNameCheck.class,
49 AbstractNameCheck.MSG_INVALID_PATTERN, "ARR", pattern1),
50
51 };
52
53 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
54 }
55
56 @Test
57 public void testExample2() throws Exception {
58 final String[] expected = {
59 "19:15: " + getCheckMessage(ParameterNumberCheck.class,
60 ParameterNumberCheck.MSG_KEY, 7, 8),
61
62 };
63
64 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
65 }
66
67 @Test
68 public void testExample3() throws Exception {
69 final String[] expected = {
70 "18:15: " + getCheckMessage(ParameterNumberCheck.class,
71 ParameterNumberCheck.MSG_KEY, 7, 8),
72 };
73
74 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
75 }
76
77 @Test
78 public void testExample4() throws Exception {
79 final String[] expected = {
80 "18:15: " + getCheckMessage(ParameterNumberCheck.class,
81 ParameterNumberCheck.MSG_KEY, 7, 8),
82 };
83
84 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
85 }
86 }