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.sizes;
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 MethodCountCheckExamplesTest extends AbstractExamplesModuleTestSupport {
28
29 @Override
30 public String getPackageLocation() {
31 return "com/puppycrawl/tools/checkstyle/checks/sizes/methodcount";
32 }
33
34 @Test
35 public void testExample1() throws Exception {
36 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
37 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
38 }
39
40 @Test
41 public void testExample2() throws Exception {
42 final String[] expected = {
43 "13:1: " + getCheckMessage(MethodCountCheck.MSG_MANY_METHODS, 6, 5),
44 };
45
46 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
47 }
48
49 @Test
50 public void testExample3() throws Exception {
51 final String[] expected = {
52 "14:1: " + getCheckMessage(MethodCountCheck.MSG_PUBLIC_METHODS, 3, 2),
53 };
54
55 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
56 }
57
58 @Test
59 public void testExample4() throws Exception {
60 final String[] expected = {
61 "13:1: " + getCheckMessage(MethodCountCheck.MSG_PRIVATE_METHODS, 2, 1),
62 };
63
64 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
65 }
66
67 @Test
68 public void testExample5() throws Exception {
69 final String[] expected = {
70 "13:1: " + getCheckMessage(MethodCountCheck.MSG_PACKAGE_METHODS, 1, 0),
71 };
72
73 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
74 }
75
76 @Test
77 public void testExample6() throws Exception {
78 final String[] expected = {};
79
80 verifyWithInlineConfigParser(getPath("Example6.java"), expected);
81 }
82
83 @Test
84 public void testExample7() throws Exception {
85 final String[] expected = {
86 "14:1: " + getCheckMessage(MethodCountCheck.MSG_MANY_METHODS, 6, 2),
87 };
88
89 verifyWithInlineConfigParser(getPath("Example7.java"), expected);
90 }
91
92 }