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