1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.google.checkstyle.test.chapter5naming.rule526parameternames;
21
22 import java.util.Map;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;
27 import com.puppycrawl.tools.checkstyle.api.Configuration;
28
29 public class ParameterNameTest extends AbstractGoogleModuleTestSupport {
30
31 private static final String MSG_KEY = "name.invalidPattern";
32
33 @Override
34 protected String getPackageLocation() {
35 return "com/google/checkstyle/test/chapter5naming/rule526parameternames";
36 }
37
38 @Test
39 public void testGeneralParameterName() throws Exception {
40 final Configuration config = getModuleConfig("ParameterName");
41 final String format = config.getProperty("format");
42 final Map<String, String> messages = config.getMessages();
43 final String[] expected = {
44 "10:21: " + getCheckMessage(messages, MSG_KEY, "bB", format),
45 "33:18: " + getCheckMessage(messages, MSG_KEY, "llll_llll", format),
46 "34:21: " + getCheckMessage(messages, MSG_KEY, "bB", format),
47 "64:13: " + getCheckMessage(messages, MSG_KEY, "$arg1", format),
48 "65:13: " + getCheckMessage(messages, MSG_KEY, "ar$g2", format),
49 "66:13: " + getCheckMessage(messages, MSG_KEY, "arg3$", format),
50 "67:13: " + getCheckMessage(messages, MSG_KEY, "a_rg4", format),
51 "68:13: " + getCheckMessage(messages, MSG_KEY, "_arg5", format),
52 "69:13: " + getCheckMessage(messages, MSG_KEY, "arg6_", format),
53 "70:13: " + getCheckMessage(messages, MSG_KEY, "aArg7", format),
54 "71:13: " + getCheckMessage(messages, MSG_KEY, "aArg8", format),
55 "72:13: " + getCheckMessage(messages, MSG_KEY, "aar_g", format),
56 };
57
58 final String filePath = getPath("InputParameterName.java");
59
60 final Integer[] warnList = getLinesWithWarn(filePath);
61 verify(config, filePath, expected, warnList);
62 }
63
64 }