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