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.coding;
21
22 import static com.google.common.truth.Truth.assertWithMessage;
23 import static com.puppycrawl.tools.checkstyle.checks.coding.ConstructorsDeclarationGroupingCheck.MSG_KEY;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
28
29 public class ConstructorsDeclarationGroupingCheckTest extends AbstractModuleTestSupport {
30 @Override
31 protected String getPackageLocation() {
32 return "com/puppycrawl/tools/checkstyle/checks/coding/constructorsdeclarationgrouping";
33 }
34
35 @Test
36 public void testDefault() throws Exception {
37 final String[] expected = {
38 "23:5: " + getCheckMessage(MSG_KEY, 19),
39 "28:5: " + getCheckMessage(MSG_KEY, 19),
40 "45:9: " + getCheckMessage(MSG_KEY, 39),
41 "55:13: " + getCheckMessage(MSG_KEY, 49),
42 "59:9: " + getCheckMessage(MSG_KEY, 39),
43 "63:5: " + getCheckMessage(MSG_KEY, 19),
44 "66:5: " + getCheckMessage(MSG_KEY, 19),
45 };
46 verifyWithInlineConfigParser(
47 getPath("InputConstructorsDeclarationGrouping.java"), expected);
48 }
49
50 @Test
51 public void testConstructorsDeclarationGroupingInner() throws Exception {
52 final String[] expected = {
53 "29:9: " + getCheckMessage(MSG_KEY, 25),
54 "34:9: " + getCheckMessage(MSG_KEY, 25),
55 "37:9: " + getCheckMessage(MSG_KEY, 25),
56 "41:5: " + getCheckMessage(MSG_KEY, 11),
57
58 };
59 verifyWithInlineConfigParser(
60 getPath("InputConstructorsDeclarationGroupingInner.java"), expected);
61 }
62
63 @Test
64 public void testConstructorsDeclarationGroupingRecords() throws Exception {
65
66 final String[] expected = {
67 "20:9: " + getCheckMessage(MSG_KEY, 12),
68 "23:9: " + getCheckMessage(MSG_KEY, 12),
69 "28:9: " + getCheckMessage(MSG_KEY, 12),
70 "45:9: " + getCheckMessage(MSG_KEY, 39),
71 };
72
73 verifyWithInlineConfigParser(
74 getNonCompilablePath("InputConstructorsDeclarationGroupingRecords.java"),
75 expected);
76 }
77
78 @Test
79 public void testTokensNotNull() {
80 final ConstructorsDeclarationGroupingCheck check =
81 new ConstructorsDeclarationGroupingCheck();
82 assertWithMessage("Acceptable tokens should not be null")
83 .that(check.getAcceptableTokens())
84 .isNotNull();
85 assertWithMessage("Default tokens should not be null")
86 .that(check.getDefaultTokens())
87 .isNotNull();
88 assertWithMessage("Required tokens should not be null")
89 .that(check.getRequiredTokens())
90 .isNotNull();
91 }
92
93 }