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