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 "85:7: " + getCheckMessage(MSG_KEY, 81),
46 "90:7: " + getCheckMessage(MSG_KEY, 81),
47 "93:7: " + getCheckMessage(MSG_KEY, 81),
48 "97:5: " + getCheckMessage(MSG_KEY, 19),
49 };
50 verifyWithInlineConfigParser(
51 getPath("InputConstructorsDeclarationGrouping.java"), expected);
52 }
53
54 @Test
55 public void testConstructorsDeclarationGroupingRecords() throws Exception {
56
57 final String[] expected = {
58 "20:9: " + getCheckMessage(MSG_KEY, 12),
59 "23:9: " + getCheckMessage(MSG_KEY, 12),
60 "28:9: " + getCheckMessage(MSG_KEY, 12),
61 "45:9: " + getCheckMessage(MSG_KEY, 39),
62 };
63
64 verifyWithInlineConfigParser(
65 getNonCompilablePath("InputConstructorsDeclarationGroupingRecords.java"),
66 expected);
67 }
68
69 @Test
70 public void testTokensNotNull() {
71 final ConstructorsDeclarationGroupingCheck check =
72 new ConstructorsDeclarationGroupingCheck();
73 assertWithMessage("Acceptable tokens should not be null")
74 .that(check.getAcceptableTokens())
75 .isNotNull();
76 assertWithMessage("Default tokens should not be null")
77 .that(check.getDefaultTokens())
78 .isNotNull();
79 assertWithMessage("Required tokens should not be null")
80 .that(check.getRequiredTokens())
81 .isNotNull();
82 }
83
84 }