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.design;
21
22 import static com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck.MSG_KEY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class DesignForExtensionCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/design/designforextension";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = {
38 "15:3: " + getCheckMessage(MSG_KEY, "Example1", "m1"),
39 "18:3: " + getCheckMessage(MSG_KEY, "Example1", "m2"),
40 "43:3: " + getCheckMessage(MSG_KEY, "Example1", "toString"),
41 };
42
43 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
44 }
45
46 @Test
47 public void testExample2() throws Exception {
48 final String[] expected = {
49 "17:3: " + getCheckMessage(MSG_KEY, "Example2", "m1"),
50 "20:3: " + getCheckMessage(MSG_KEY, "Example2", "m2"),
51 };
52
53 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
54 }
55
56 @Test
57 public void testExample3() throws Exception {
58 final String[] expected = {
59 "17:3: " + getCheckMessage(MSG_KEY, "Example3", "m1"),
60 "20:3: " + getCheckMessage(MSG_KEY, "Example3", "m2"),
61 "37:3: " + getCheckMessage(MSG_KEY, "Example3", "m7"),
62 "43:3: " + getCheckMessage(MSG_KEY, "Example3", "m8"),
63 "45:3: " + getCheckMessage(MSG_KEY, "Example3", "toString"),
64 };
65
66 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
67 }
68
69 @Test
70 public void testUseCase1() throws Exception {
71 final String[] expected = {
72 "18:3: " + getCheckMessage(MSG_KEY, "UseCase1", "m1"),
73 "21:3: " + getCheckMessage(MSG_KEY, "UseCase1", "m2"),
74 "38:3: " + getCheckMessage(MSG_KEY, "UseCase1", "m7"),
75 "46:3: " + getCheckMessage(MSG_KEY, "UseCase1", "toString"),
76 };
77
78 verifyWithInlineConfigParser(getPath("UseCase1.java"), expected);
79 }
80
81 }