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.coding;
21
22 import static com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class HiddenFieldCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/coding/hiddenfield";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = {
38 "16:19: " + getCheckMessage(MSG_KEY, "testField"),
39 "19:12: " + getCheckMessage(MSG_KEY, "field"),
40 "21:28: " + getCheckMessage(MSG_KEY, "testField"),
41 "24:24: " + getCheckMessage(MSG_KEY, "field"),
42 "28:32: " + getCheckMessage(MSG_KEY, "field"),
43 };
44
45 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
46 }
47
48 @Test
49 public void testExample2() throws Exception {
50 final String[] expected = {
51 "21:12: " + getCheckMessage(MSG_KEY, "field"),
52 };
53
54 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
55 }
56
57 @Test
58 public void testExample3() throws Exception {
59 final String[] expected = {
60 "21:12: " + getCheckMessage(MSG_KEY, "field"),
61 "26:24: " + getCheckMessage(MSG_KEY, "field"),
62 "30:32: " + getCheckMessage(MSG_KEY, "field"),
63 };
64
65 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
66 }
67
68 @Test
69 public void testExample4() throws Exception {
70 final String[] expected = {
71 "21:12: " + getCheckMessage(MSG_KEY, "field"),
72 "23:28: " + getCheckMessage(MSG_KEY, "testField"),
73 "26:24: " + getCheckMessage(MSG_KEY, "field"),
74 "30:32: " + getCheckMessage(MSG_KEY, "field"),
75 };
76
77 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
78 }
79
80 @Test
81 public void testExample5() throws Exception {
82 final String[] expected = {
83 "18:19: " + getCheckMessage(MSG_KEY, "testField"),
84 "21:12: " + getCheckMessage(MSG_KEY, "field"),
85 "30:32: " + getCheckMessage(MSG_KEY, "field"),
86 };
87
88 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
89 }
90
91 @Test
92 public void testExample6() throws Exception {
93 final String[] expected = {
94 "19:19: " + getCheckMessage(MSG_KEY, "testField"),
95 "22:12: " + getCheckMessage(MSG_KEY, "field"),
96 "31:32: " + getCheckMessage(MSG_KEY, "field"),
97 };
98
99 verifyWithInlineConfigParser(getPath("Example6.java"), expected);
100 }
101
102 @Test
103 public void testExample7() throws Exception {
104 final String[] expected = {
105 "18:19: " + getCheckMessage(MSG_KEY, "testField"),
106 "21:12: " + getCheckMessage(MSG_KEY, "field"),
107 "23:28: " + getCheckMessage(MSG_KEY, "testField"),
108 "26:24: " + getCheckMessage(MSG_KEY, "field"),
109 };
110
111 verifyWithInlineConfigParser(getPath("Example7.java"), expected);
112 }
113
114 }