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.RedundantImportCheck.MSG_DUPLICATE;
23 import static com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck.MSG_LANG;
24 import static com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck.MSG_SAME;
25
26 import org.junit.jupiter.api.Test;
27
28 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
29
30 public class RedundantImportCheckExamplesTest extends AbstractExamplesModuleTestSupport {
31
32 @Override
33 public String getPackageLocation() {
34 return "com/puppycrawl/tools/checkstyle/checks/imports/redundantimport";
35 }
36
37 @Test
38 public void testExample1() throws Exception {
39 final String[] expected = {
40 "16:1: " + getCheckMessage(MSG_SAME,
41 "com.puppycrawl.tools.checkstyle.checks.imports.redundantimport.Example1"),
42 "17:1: " + getCheckMessage(MSG_LANG, "java.lang.String"),
43 "19:1: " + getCheckMessage(MSG_DUPLICATE, 18, "java.util.Scanner"),
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_DUPLICATE, 14, "java.base"),
53 };
54
55 verifyWithInlineConfigParser(getNonCompilablePath("Example2.java"), expected);
56 }
57
58 }