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.UnusedPrivateFieldCheck.MSG_PRIVATE_FIELD;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class UnusedPrivateFieldCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32
33 return "com/puppycrawl/tools/checkstyle/checks/coding/unusedprivatefield";
34 }
35
36 @Test
37 public void testExample1() throws Exception {
38 final String[] expected = {
39 "18:18: " + getCheckMessage(MSG_PRIVATE_FIELD, "_id"),
40 "22:15: " + getCheckMessage(MSG_PRIVATE_FIELD, "unused"),
41 "30:15: " + getCheckMessage(MSG_PRIVATE_FIELD, "getter"),
42 "36:28: " + getCheckMessage(MSG_PRIVATE_FIELD, "CONSTANT"),
43
44 };
45
46 verifyWithInlineConfigParser(
47 getPath("Example1.java"), expected);
48 }
49
50 @Test
51 public void testExample2() throws Exception {
52 final String[] expected = {
53 "24:15: " + getCheckMessage(MSG_PRIVATE_FIELD, "unused"),
54 "38:28: " + getCheckMessage(MSG_PRIVATE_FIELD, "CONSTANT"),
55 };
56
57 verifyWithInlineConfigParser(
58 getPath("Example2.java"), expected);
59 }
60
61 @Test
62 public void testExample3() throws Exception {
63 final String[] expected = {
64 "38:28: " + getCheckMessage(MSG_PRIVATE_FIELD, "CONSTANT"),
65 };
66
67 verifyWithInlineConfigParser(
68 getPath("Example3.java"), expected);
69 }
70
71 }