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