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.metrics;
21
22 import org.junit.jupiter.api.Test;
23
24 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
25 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
26
27 public class ClassFanOutComplexityCheckExamplesTest
28 extends AbstractExamplesModuleTestSupport {
29
30 @Override
31 public String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/metrics/classfanoutcomplexity";
33 }
34
35 @Test
36 public void testExample1() throws Exception {
37 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
38 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
39 }
40
41 @Test
42 public void testExample2() throws Exception {
43 final String[] expected = {
44 "23:1: " + getCheckMessage(ClassFanOutComplexityCheck.MSG_KEY, 5, 2),
45 };
46
47 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
48 }
49
50 @Test
51 public void testExample3() throws Exception {
52 final String[] expected = {
53 "24:1: " + getCheckMessage(ClassFanOutComplexityCheck.MSG_KEY, 7, 3),
54 };
55
56 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
57 }
58
59 @Test
60 public void testExample4() throws Exception {
61 final String[] expected = {
62 "24:1: " + getCheckMessage(ClassFanOutComplexityCheck.MSG_KEY, 4, 3),
63 };
64 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
65 }
66
67 @Test
68 public void testExample5() throws Exception {
69 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
70 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
71 }
72
73 @Test
74 public void testUseCase1() throws Exception {
75 final String[] expected = {
76 "24:1: " + getCheckMessage(ClassFanOutComplexityCheck.MSG_KEY, 4, 3),
77 };
78
79 verifyWithInlineConfigParser(getPath("UseCase1.java"), expected);
80 }
81
82 }