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