Skip to content

Commit

Permalink
Issue #14715: Enforced new naming convention in IT area 19
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and nrmancuso committed Apr 23, 2024
1 parent 6269e84 commit 72cf172
Show file tree
Hide file tree
Showing 32 changed files with 81 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testSimple() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonAfterOuterTypeDeclaration.java"));
"InputXpathUnnecessarySemicolonAfterOuterTypeDeclarationSimple.java"));
final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);
final String[] expectedViolation = {
"5:2: " + getCheckMessage(CLASS,
Expand All @@ -56,9 +56,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testInnerTypes() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationInnerTypes"
"InputXpathUnnecessarySemicolonAfterOuterTypeDeclarationInnerTypes"
+ ".java"));
final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);
final String[] expectedViolation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected String getCheckName() {
@Test
public void testDefault() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMemberDeclaration.java"));
"InputXpathUnnecessarySemicolonAfterTypeMemberDeclarationDefault.java"));
final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);
final String[] expectedViolation = {
"4:20: " + getCheckMessage(CLASS,
Expand All @@ -52,7 +52,7 @@ public void testDefault() throws Exception {
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text="
+ "'SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMemberDeclaration']]"
+ "'InputXpathUnnecessarySemicolonAfterTypeMemberDeclarationDefault']]"
+ "/OBJBLOCK/SEMI"
);

Expand All @@ -62,7 +62,7 @@ public void testDefault() throws Exception {
@Test
public void testTokens() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTokens"
"InputXpathUnnecessarySemicolonAfterTypeMemberDeclarationTokens"
+ ".java"));
final DefaultConfiguration moduleConfig = createModuleConfig(CLASS);
moduleConfig.addProperty("tokens", "METHOD_DEF");
Expand All @@ -74,7 +74,7 @@ public void testTokens() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[."
+ "/IDENT[@text='SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMember"
+ "/IDENT[@text='InputXpathUnnecessarySemicolonAfterTypeMember"
+ "DeclarationTokens']]"
+ "/OBJBLOCK/SEMI[1]"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testSimple() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionUnnecessarySemicolonInEnumeration.java"));
getPath("InputXpathUnnecessarySemicolonInEnumerationSimple.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UnnecessarySemicolonInEnumerationCheck.class);
Expand All @@ -60,9 +60,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testAll() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonInEnumerationAll.java"
"InputXpathUnnecessarySemicolonInEnumerationAll.java"
));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/ENUM_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionUnnecessarySemicolonInEnumerationAll']]"
+ "'InputXpathUnnecessarySemicolonInEnumerationAll']]"
+ "/OBJBLOCK/SEMI"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected String getCheckName() {
@Test
public void testDefault() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionUnnecessarySemicolonInTryWithResources.java"));
getPath("InputXpathUnnecessarySemicolonInTryWithResourcesDefault.java"));
final DefaultConfiguration moduleConfig =
createModuleConfig(UnnecessarySemicolonInTryWithResourcesCheck.class);
final String[] expectedViolation = {
Expand All @@ -51,17 +51,17 @@ public void testDefault() throws Exception {
};
final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionUnnecessarySemicolonInTryWithResources']]"
+ "'InputXpathUnnecessarySemicolonInTryWithResourcesDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='m']]/SLIST/LITERAL_TRY"
+ "/RESOURCE_SPECIFICATION/SEMI"
);
runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
}

@Test
public void testAllowWhenNoBraceAfterSemicolon() throws Exception {
public void testNoBrace() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnnecessarySemicolonInTryWithResourcesNoBrace.java"
"InputXpathUnnecessarySemicolonInTryWithResourcesNoBrace.java"
));

final DefaultConfiguration moduleConfig =
Expand All @@ -75,7 +75,7 @@ public void testAllowWhenNoBraceAfterSemicolon() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionUnnecessarySemicolonInTryWithResourcesNoBrace']]"
+ "'InputXpathUnnecessarySemicolonInTryWithResourcesNoBrace']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]"
+ "/SLIST/LITERAL_TRY/RESOURCE_SPECIFICATION/SEMI"
);
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 testUnusedImports() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionUnusedImportsOne.java"));
new File(getPath("InputXpathUnusedImports.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UnusedImportsCheck.class);
Expand All @@ -58,9 +58,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testStatic() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionUnusedImportsTwo.java"));
new File(getPath("InputXpathUnusedImportsStatic.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UnusedImportsCheck.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected String getCheckName() {
@Test
public void testOne() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnusedLocalVariableOne.java"));
"InputXpathUnusedLocalVariableOne.java"));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableOne']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableOne']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF[./IDENT[@text='a']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableOne']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableOne']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='a']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableOne']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableOne']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='a']]/TYPE",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableOne']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableOne']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='a']]/TYPE/LITERAL_INT"
);
Expand All @@ -74,7 +74,7 @@ public void testOne() throws Exception {
@Test
public void testTwo() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionUnusedLocalVariableTwo.java"));
"InputXpathUnusedLocalVariableTwo.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UnusedLocalVariableCheck.class);
Expand All @@ -86,17 +86,17 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF[./IDENT[@text='b']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='b']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "@text='InputXpathUnusedLocalVariableTwo']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='b']]/TYPE", "/COMPILATION_UNIT/CLASS_DEF["
+ "./IDENT[@text='SuppressionXpathRegressionUnusedLocalVariableTwo']]/"
+ "./IDENT[@text='InputXpathUnusedLocalVariableTwo']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF["
+ "./IDENT[@text='b']]/TYPE/LITERAL_INT"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected String getCheckName() {
@Test
public void testUpperEllOne() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionUpperEllFirst.java"));
new File(getPath("InputXpathUpperEllOne.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UpperEllCheck.class);
Expand All @@ -52,10 +52,10 @@ public void testUpperEllOne() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionUpperEllFirst']]/OBJBLOCK"
+ "[./IDENT[@text='InputXpathUpperEllOne']]/OBJBLOCK"
+ "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR[./NUM_LONG[@text='0l']]",
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionUpperEllFirst']]/OBJBLOCK"
+ "[./IDENT[@text='InputXpathUpperEllOne']]/OBJBLOCK"
+ "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR"
+ "/NUM_LONG[@text='0l']"
);
Expand All @@ -67,7 +67,7 @@ public void testUpperEllOne() throws Exception {
@Test
public void testUpperEllTwo() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionUpperEllSecond.java"));
new File(getPath("InputXpathUpperEllTwo.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(UpperEllCheck.class);
Expand All @@ -79,11 +79,11 @@ public void testUpperEllTwo() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/INTERFACE_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionUpperEllSecond']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='InputXpathUpperEllTwo']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[./IDENT[@text='var2']]/ASSIGN/EXPR"
+ "[./NUM_LONG[@text='508987l']]",
"/COMPILATION_UNIT/INTERFACE_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionUpperEllSecond']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='InputXpathUpperEllTwo']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[./IDENT[@text='var2']]/ASSIGN/EXPR"
+ "/NUM_LONG[@text='508987l']"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected String getCheckName() {
@Test
public void testOne() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionVariableDeclarationUsageDistance1.java"));
"InputXpathVariableDeclarationUsageDistanceOne.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VariableDeclarationUsageDistanceCheck.class);
Expand All @@ -55,19 +55,19 @@ public void testOne() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance1']]/"
+ "'InputXpathVariableDeclarationUsageDistanceOne']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='temp']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance1']]/"
+ "'InputXpathVariableDeclarationUsageDistanceOne']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='temp']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance1']]/"
+ "'InputXpathVariableDeclarationUsageDistanceOne']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='temp']]/TYPE",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance1']]/"
+ "'InputXpathVariableDeclarationUsageDistanceOne']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='temp']]/TYPE/LITERAL_INT"
);
Expand All @@ -79,7 +79,7 @@ public void testOne() throws Exception {
@Test
public void testTwo() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionVariableDeclarationUsageDistance2.java"));
"InputXpathVariableDeclarationUsageDistanceTwo.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VariableDeclarationUsageDistanceCheck.class);
Expand All @@ -96,19 +96,19 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance2']]"
+ "'InputXpathVariableDeclarationUsageDistanceTwo']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod2']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='count']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance2']]"
+ "'InputXpathVariableDeclarationUsageDistanceTwo']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod2']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='count']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance2']]"
+ "'InputXpathVariableDeclarationUsageDistanceTwo']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod2']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='count']]/TYPE",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionVariableDeclarationUsageDistance2']]"
+ "'InputXpathVariableDeclarationUsageDistanceTwo']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod2']]"
+ "/SLIST/VARIABLE_DEF[./IDENT[@text='count']]/TYPE/LITERAL_INT"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected String getCheckName() {
@Test
public void testWhitespaceAfterTypecast() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionWhitespaceAfterTypecast.java"));
new File(getPath("InputXpathWhitespaceAfterTypecast.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionWhitespaceAfterTypecast']]/OBJBLOCK"
+ "@text='InputXpathWhitespaceAfterTypecast']]/OBJBLOCK"
+ "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR/TYPECAST/RPAREN"
);

Expand All @@ -63,7 +63,7 @@ public void testWhitespaceAfterTypecast() throws Exception {
@Test
public void testWhitespaceAfterNotFollowed() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionWhitespaceAfterNotFollowed.java"));
new File(getPath("InputXpathWhitespaceAfterNotFollowed.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionWhitespaceAfterNotFollowed']]/OBJBLOCK"
+ "@text='InputXpathWhitespaceAfterNotFollowed']]/OBJBLOCK"
+ "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/ARRAY_INIT/COMMA"
);

Expand Down
Loading

0 comments on commit 72cf172

Please sign in to comment.