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.modules;
21
22 import static com.puppycrawl.tools.checkstyle.checks.modules.ModuleDirectiveOrderCheck.MSG_GROUPING;
23 import static com.puppycrawl.tools.checkstyle.checks.modules.ModuleDirectiveOrderCheck.MSG_ORDER;
24 import static com.puppycrawl.tools.checkstyle.checks.modules.ModuleDirectiveOrderCheck.MSG_SEPARATED_INTERNALLY;
25 import static com.puppycrawl.tools.checkstyle.checks.modules.ModuleDirectiveOrderCheck.MSG_SEPARATION;
26
27 import org.junit.jupiter.api.Test;
28
29 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
30 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
31
32 public class ModuleDirectiveOrderExamplesTest extends AbstractExamplesModuleTestSupport {
33
34 @Override
35 public String getPackageLocation() {
36 return "com/puppycrawl/tools/checkstyle/checks/modules/moduledirectiveorder";
37 }
38
39 @Test
40 public void testExample1() throws Exception {
41 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
42
43 verifyWithInlineConfigParser(getNonCompilablePath("Example1.java"), expected);
44 }
45
46 @Test
47 public void testExample2() throws Exception {
48 final String[] expected = {
49 "18:3: " + getCheckMessage(MSG_ORDER, "uses", "exports"),
50 };
51
52 verifyWithInlineConfigParser(getNonCompilablePath("Example2.java"), expected);
53 }
54
55 @Test
56 public void testExample3() throws Exception {
57 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
58
59 verifyWithInlineConfigParser(getNonCompilablePath("Example3.java"), expected);
60 }
61
62 @Test
63 public void testUseCase1() throws Exception {
64 final String[] expected = {
65 "14:3: " + getCheckMessage(MSG_ORDER, "requires", "exports"),
66 };
67
68 verifyWithInlineConfigParser(getNonCompilablePath("UseCase1.java"), expected);
69 }
70
71 @Test
72 public void testUseCase2() throws Exception {
73 final String[] expected = {
74 "13:3: " + getCheckMessage(MSG_SEPARATION, "exports"),
75 };
76
77 verifyWithInlineConfigParser(getNonCompilablePath("UseCase2.java"), expected);
78 }
79
80 @Test
81 public void testUseCase3() throws Exception {
82 final String[] expected = {
83 "15:3: " + getCheckMessage(MSG_SEPARATION, "exports"),
84 };
85
86 verifyWithInlineConfigParser(getNonCompilablePath("UseCase3.java"), expected);
87 }
88
89 @Test
90 public void testUseCase4() throws Exception {
91 final String[] expected = {
92 "16:3: " + getCheckMessage(MSG_GROUPING, "requires"),
93 };
94
95 verifyWithInlineConfigParser(getNonCompilablePath("UseCase4.java"), expected);
96 }
97
98 @Test
99 public void testUseCase5() throws Exception {
100 final String[] expected = {
101 "14:3: " + getCheckMessage(MSG_SEPARATED_INTERNALLY, "requires"),
102 };
103
104 verifyWithInlineConfigParser(getNonCompilablePath("UseCase5.java"), expected);
105 }
106
107 }