Skip to content

Commit

Permalink
Issue #14715: Enforce new namingconvention in IT area 22
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and rnveach committed Apr 22, 2024
1 parent 05981e0 commit 1fc5987
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 103 deletions.
Expand Up @@ -36,9 +36,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testDefault() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodCount1.java")
getPath("InputXpathMethodCountDefault.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -52,24 +52,24 @@ public void testOne() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]",
+ "[./IDENT[@text='InputXpathMethodCountDefault']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]"
+ "[./IDENT[@text='InputXpathMethodCountDefault']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]"
+ "[./IDENT[@text='InputXpathMethodCountDefault']]"
+ "/LITERAL_CLASS"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
}

@Test
public void testTwo() throws Exception {
public void testPrivate() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodCount2.java")
getPath("InputXpathMethodCountPrivate.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -83,24 +83,24 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount2']]",
+ "[./IDENT[@text='InputXpathMethodCountPrivate']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount2']]"
+ "[./IDENT[@text='InputXpathMethodCountPrivate']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount2']]"
+ "[./IDENT[@text='InputXpathMethodCountPrivate']]"
+ "/LITERAL_CLASS"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
}

@Test
public void testThree() throws Exception {
public void testPackage() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodCount1.java")
getPath("InputXpathMethodCountDefault.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -114,24 +114,24 @@ public void testThree() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]",
+ "[./IDENT[@text='InputXpathMethodCountDefault']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]"
+ "[./IDENT[@text='InputXpathMethodCountDefault']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount1']]"
+ "[./IDENT[@text='InputXpathMethodCountDefault']]"
+ "/LITERAL_CLASS"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
}

@Test
public void testFour() throws Exception {
public void testProtected() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodCount3.java")
getPath("InputXpathMethodCountProtected.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -145,24 +145,24 @@ public void testFour() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount3']]",
+ "[./IDENT[@text='InputXpathMethodCountProtected']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount3']]"
+ "[./IDENT[@text='InputXpathMethodCountProtected']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount3']]"
+ "[./IDENT[@text='InputXpathMethodCountProtected']]"
+ "/LITERAL_CLASS"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
}

@Test
public void testFive() throws Exception {
public void testPublic() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodCount4.java")
getPath("InputXpathMethodCountPublic.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -176,14 +176,14 @@ public void testFive() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount4']]",
+ "[./IDENT[@text='InputXpathMethodCountPublic']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount4']]"
+ "[./IDENT[@text='InputXpathMethodCountPublic']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodCount4']]"
+ "[./IDENT[@text='InputXpathMethodCountPublic']]"
+ "/LITERAL_CLASS"
);

Expand Down
Expand Up @@ -42,29 +42,29 @@ protected String getCheckName() {
@Test
public void testSimple() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodLengthSimple.java"));
new File(getPath("InputXpathMethodLengthSimple.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(MethodLengthCheck.class);
moduleConfig.addProperty("max", "10");

final String[] expectedViolations = {
"4:5: " + getCheckMessage(MethodLengthCheck.class, MSG_KEY,
11, 10, "SuppressionXpathRegressionMethodLengthSimple"),
11, 10, "InputXpathMethodLengthSimple"),
};

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]"
+ "[@text='InputXpathMethodLengthSimple']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]",
+ "[@text='InputXpathMethodLengthSimple']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]"
+ "[@text='InputXpathMethodLengthSimple']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]/MODIFIERS",
+ "[@text='InputXpathMethodLengthSimple']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]"
+ "[@text='InputXpathMethodLengthSimple']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSimple']]"
+ "[@text='InputXpathMethodLengthSimple']]"
+ "/MODIFIERS/LITERAL_PROTECTED"
);

Expand All @@ -74,7 +74,7 @@ public void testSimple() throws Exception {
@Test
public void testNoEmptyLines() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodLengthNoEmptyLines.java"));
new File(getPath("InputXpathMethodLengthNoEmptyLines.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(MethodLengthCheck.class);
moduleConfig.addProperty("max", "5");
Expand All @@ -87,13 +87,13 @@ public void testNoEmptyLines() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthNoEmptyLines']]"
+ "[@text='InputXpathMethodLengthNoEmptyLines']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthNoEmptyLines']]"
+ "[@text='InputXpathMethodLengthNoEmptyLines']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthNoEmptyLines']]"
+ "[@text='InputXpathMethodLengthNoEmptyLines']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]"
+ "/MODIFIERS/LITERAL_PROTECTED"
);
Expand All @@ -104,7 +104,7 @@ public void testNoEmptyLines() throws Exception {
@Test
public void testSingleToken() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionMethodLengthSingleToken.java"));
getPath("InputXpathMethodLengthSingleToken.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(MethodLengthCheck.class);
moduleConfig.addProperty("max", "1");
Expand All @@ -116,19 +116,19 @@ public void testSingleToken() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='a']]/ASSIGN/EXPR/LITERAL_NEW"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[./IDENT[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='a']]/ASSIGN/EXPR/LITERAL_NEW"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[./IDENT[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='a']]/ASSIGN/EXPR/LITERAL_NEW"
+ "[./IDENT[@text='SuppressionXpathRegressionMethodLengthSingleToken']]"
+ "[./IDENT[@text='InputXpathMethodLengthSingleToken']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
);
Expand Down
Expand Up @@ -39,9 +39,9 @@ protected String getCheckName() {
}

@Test
public void test1() throws Exception {
public void testDefault() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodName1.java"));
new File(getPath("InputXpathMethodNameDefault.java"));

final String pattern = "^[a-z][a-zA-Z0-9]*$";
final DefaultConfiguration moduleConfig =
Expand All @@ -55,17 +55,17 @@ public void test1() throws Exception {
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text"
+ "='SuppressionXpathRegressionMethodName1']]"
+ "='InputXpathMethodNameDefault']]"
+ "/OBJBLOCK/METHOD_DEF/IDENT[@text='SecondMethod']"
);
runVerifications(moduleConfig, fileToProcess, expectedViolation,
expectedXpathQueries);
}

@Test
public void test2() throws Exception {
public void testInnerClass() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodName2.java"));
new File(getPath("InputXpathMethodNameInner.java"));

final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$";
final DefaultConfiguration moduleConfig =
Expand All @@ -80,7 +80,7 @@ public void test2() throws Exception {
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text"
+ "='SuppressionXpathRegressionMethodName2']]"
+ "='InputXpathMethodNameInner']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Inner']]"
+ "/OBJBLOCK/METHOD_DEF/IDENT[@text='MyMethod2']"
);
Expand All @@ -89,9 +89,9 @@ public void test2() throws Exception {
}

@Test
public void test3() throws Exception {
public void testCustomProperties() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodName3.java"));
new File(getPath("InputXpathMethodNameCustomProperties.java"));

final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$";
final DefaultConfiguration moduleConfig =
Expand Down
Expand Up @@ -40,7 +40,7 @@ protected String getCheckName() {
@Test
public void testOne() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodParamPadOne.java"));
new File(getPath("InputXpathMethodParamPadOne.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodParamPadCheck.class);
Expand All @@ -52,7 +52,7 @@ public void testOne() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodParamPadOne']]/OBJBLOCK"
+ "[@text='InputXpathMethodParamPadOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='InputMethodParamPad']]/LPAREN"
);

Expand All @@ -63,7 +63,7 @@ public void testOne() throws Exception {
@Test
public void testTwo() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodParamPadTwo.java"));
new File(getPath("InputXpathMethodParamPadTwo.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodParamPadCheck.class);
Expand All @@ -75,7 +75,7 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodParamPadTwo']]/OBJBLOCK"
+ "[@text='InputXpathMethodParamPadTwo']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='sayHello']]/LPAREN"
);

Expand All @@ -86,7 +86,7 @@ public void testTwo() throws Exception {
@Test
public void testThree() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodParamPadThree.java"));
new File(getPath("InputXpathMethodParamPadThree.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodParamPadCheck.class);
Expand All @@ -99,7 +99,7 @@ public void testThree() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodParamPadThree']]/OBJBLOCK"
+ "[@text='InputXpathMethodParamPadThree']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='sayHello']]/LPAREN"
);

Expand Down

0 comments on commit 1fc5987

Please sign in to comment.