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.imports;
21
22 import static com.puppycrawl.tools.checkstyle.checks.imports.AvoidModuleImportCheck.MSG_COUNT;
23 import static com.puppycrawl.tools.checkstyle.checks.imports.AvoidModuleImportCheck.MSG_KEY;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
28 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
29
30 public class AvoidModuleImportCheckExamplesTest extends AbstractExamplesModuleTestSupport {
31
32 @Override
33 public String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/imports/avoidmoduleimport";
35 }
36
37 @Test
38 public void testExample1() throws Exception {
39 final String[] expected = {
40 "14:1: " + getCheckMessage(MSG_KEY, "java.base"),
41 "16:1: " + getCheckMessage(MSG_KEY, "java.sql"),
42 };
43
44 verifyWithInlineConfigParser(
45 getNonCompilablePath("Example1.java"), expected);
46 }
47
48 @Test
49 public void testExample2() throws Exception {
50 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
51
52 verifyWithInlineConfigParser(
53 getNonCompilablePath("Example2.java"), expected);
54 }
55
56 @Test
57 public void testExample3() throws Exception {
58 final String[] expected = {
59 "18:1: " + getCheckMessage(MSG_COUNT, 1),
60 };
61
62 verifyWithInlineConfigParser(
63 getNonCompilablePath("Example3.java"), expected);
64 }
65
66 }