Skip to content

Commit

Permalink
Issue #14715: Enforced new naming convention in IT area 20
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and rnveach committed Apr 21, 2024
1 parent bb05c90 commit 05981e0
Show file tree
Hide file tree
Showing 32 changed files with 129 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testMethod() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionFinalParameters1.java"));
new File(getPath("InputXpathFinalParametersMethod.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(FinalParametersCheck.class);
Expand All @@ -51,27 +51,27 @@ public void testOne() throws Exception {

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters1']]"
+ "[@text='InputXpathFinalParametersMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]"
+ "/PARAMETERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters1']]"
+ "[@text='InputXpathFinalParametersMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters1']]"
+ "[@text='InputXpathFinalParametersMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters1']]"
+ "[@text='InputXpathFinalParametersMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/TYPE",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters1']]"
+ "[@text='InputXpathFinalParametersMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/TYPE/LITERAL_INT"
);
Expand All @@ -80,59 +80,59 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testCtor() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionFinalParameters2.java"));
new File(getPath("InputXpathFinalParametersCtor.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(FinalParametersCheck.class);

moduleConfig.addProperty("tokens", "CTOR_DEF");

final String[] expectedViolation = {
"5:55: " + getCheckMessage(FinalParametersCheck.class,
"5:42: " + getCheckMessage(FinalParametersCheck.class,
FinalParametersCheck.MSG_KEY, "argOne"),
};

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters2']]"
+ "[@text='InputXpathFinalParametersCtor']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalParameters2']]"
+ "@text='InputXpathFinalParametersCtor']]"
+ "/PARAMETERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters2']]"
+ "[@text='InputXpathFinalParametersCtor']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalParameters2']]"
+ "@text='InputXpathFinalParametersCtor']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters2']]"
+ "[@text='InputXpathFinalParametersCtor']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalParameters2']]"
+ "@text='InputXpathFinalParametersCtor']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters2']]"
+ "[@text='InputXpathFinalParametersCtor']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalParameters2']]"
+ "@text='InputXpathFinalParametersCtor']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/TYPE",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters2']]"
+ "[@text='InputXpathFinalParametersCtor']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalParameters2']]"
+ "@text='InputXpathFinalParametersCtor']]"
+ "/PARAMETERS/PARAMETER_DEF[./IDENT[@text='argOne']]/TYPE/LITERAL_INT"
);

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

@Test
public void testThree() throws Exception {
public void testAnonymous() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionFinalParameters3.java"));
new File(getPath("InputXpathFinalParametersAnonymous.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(FinalParametersCheck.class);
Expand All @@ -146,38 +146,38 @@ public void testThree() throws Exception {

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters3']]"
+ "[@text='InputXpathFinalParametersAnonymous']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='obj']]/ASSIGN/EXPR"
+ "/LITERAL_NEW[./IDENT[@text='AnonymousClass']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/PARAMETERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters3']]"
+ "[@text='InputXpathFinalParametersAnonymous']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='obj']]/ASSIGN/EXPR"
+ "/LITERAL_NEW[./IDENT[@text='AnonymousClass']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/PARAMETERS"
+ "/PARAMETER_DEF[./IDENT[@text='argOne']]",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters3']]"
+ "[@text='InputXpathFinalParametersAnonymous']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='obj']]/ASSIGN/EXPR"
+ "/LITERAL_NEW[./IDENT[@text='AnonymousClass']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/PARAMETERS"
+ "/PARAMETER_DEF[./IDENT[@text='argOne']]/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters3']]"
+ "[@text='InputXpathFinalParametersAnonymous']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='obj']]/ASSIGN/EXPR"
+ "/LITERAL_NEW[./IDENT[@text='AnonymousClass']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/PARAMETERS"
+ "/PARAMETER_DEF[./IDENT[@text='argOne']]/TYPE[./IDENT[@text='String']]",

"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionFinalParameters3']]"
+ "[@text='InputXpathFinalParametersAnonymous']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='obj']]/ASSIGN/EXPR"
+ "/LITERAL_NEW[./IDENT[@text='AnonymousClass']]/OBJBLOCK"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testRuntimeException() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalThrowsOne.java"));
new File(getPath("InputXpathIllegalThrowsRuntimeException.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionIllegalThrowsOne']]/OBJBLOCK"
+ "[./IDENT[@text='InputXpathIllegalThrowsRuntimeException']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='sayHello']]/LITERAL_THROWS"
+ "/IDENT[@text='RuntimeException']"
);
Expand All @@ -62,9 +62,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testError() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalThrowsTwo.java"));
new File(getPath("InputXpathIllegalThrowsError.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionIllegalThrowsTwo']]/OBJBLOCK"
+ "[./IDENT[@text='InputXpathIllegalThrowsError']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='methodTwo']]/LITERAL_THROWS"
+ "/DOT[./IDENT[@text='Error']]"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testLabel() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalToken1.java"));
new File(getPath("InputXpathIllegalTokenLabel.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(IllegalTokenCheck.class);
final String[] expectedViolation = {
Expand All @@ -49,7 +49,7 @@ public void testOne() throws Exception {
};
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalToken1']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenLabel']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]"
+ "/SLIST/LABELED_STAT[./IDENT[@text='outer']]"
);
Expand All @@ -59,9 +59,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testNative() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalToken2.java"));
new File(getPath("InputXpathIllegalTokenNative.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(IllegalTokenCheck.class);

Expand All @@ -73,7 +73,7 @@ public void testTwo() throws Exception {
};
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalToken2']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenNative']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]"
+ "/MODIFIERS/LITERAL_NATIVE"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testField() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalTokenText1.java"));
new File(getPath("InputXpathIllegalTokenTextField.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(IllegalTokenTextCheck.class);
moduleConfig.addProperty("format", "12345");
Expand All @@ -52,11 +52,11 @@ public void testOne() throws Exception {
};
final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText1']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenTextField']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='illegalNumber']]"
+ "/ASSIGN/EXPR[./NUM_INT[@text='12345']]",
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText1']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenTextField']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='illegalNumber']]"
+ "/ASSIGN/EXPR/NUM_INT[@text='12345']"
);
Expand All @@ -66,9 +66,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testMethod() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalTokenText2.java"));
new File(getPath("InputXpathIllegalTokenTextMethod.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(IllegalTokenTextCheck.class);
moduleConfig.addProperty("format", "forbiddenText");
Expand All @@ -79,12 +79,12 @@ public void testTwo() throws Exception {
};
final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText2']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenTextMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myMethod']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='illegalString']]"
+ "/ASSIGN/EXPR[./STRING_LITERAL[@text='forbiddenText']]",
"/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText2']]"
+ "/CLASS_DEF[./IDENT[@text='InputXpathIllegalTokenTextMethod']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myMethod']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='illegalString']]"
+ "/ASSIGN/EXPR/STRING_LITERAL[@text='forbiddenText']"
Expand All @@ -95,9 +95,9 @@ public void testTwo() throws Exception {
}

@Test
public void testThree() throws Exception {
public void testInterface() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionIllegalTokenText3.java"));
new File(getPath("InputXpathIllegalTokenTextInterface.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(IllegalTokenTextCheck.class);
moduleConfig.addProperty("format", "invalidIdentifier");
Expand All @@ -108,7 +108,7 @@ public void testThree() throws Exception {
};
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT"
+ "/INTERFACE_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText3']]"
+ "/INTERFACE_DEF[./IDENT[@text='InputXpathIllegalTokenTextInterface']]"
+ "/OBJBLOCK/METHOD_DEF/IDENT[@text='invalidIdentifier']"
);

Expand Down
Loading

0 comments on commit 05981e0

Please sign in to comment.