Skip to content

Commit

Permalink
Issue #14715: Enforced new naming convention in IT area 24
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and rnveach committed Apr 26, 2024
1 parent 145f1e1 commit 101e623
Show file tree
Hide file tree
Showing 25 changed files with 64 additions and 71 deletions.
Expand Up @@ -41,7 +41,7 @@ protected String getCheckName() {
@Test
public void testOne() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRegressionIllegalIdentifierNameTestOne.java"));
"InputXpathIllegalIdentifierNameOne.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/RECORD_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionIllegalIdentifierNameTestOne'"
+ "[./IDENT[@text='InputXpathIllegalIdentifierNameOne'"
+ "]]/RECORD_COMPONENTS/RECORD_COMPONENT_DEF/IDENT[@text='yield']"
);

Expand All @@ -66,7 +66,7 @@ public void testOne() throws Exception {
@Test
public void testTwo() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRegressionIllegalIdentifierNameTestTwo.java"));
"InputXpathIllegalIdentifierNameTwo.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionIllegalIdentifierNameTestTwo']"
+ "[./IDENT[@text='InputXpathIllegalIdentifierNameTwo']"
+ "]/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/PARAMETERS/PARAMETER_DEF"
+ "/IDENT[@text='yield']"
);
Expand Down
Expand Up @@ -38,7 +38,7 @@ protected String getCheckName() {

@Test
public void testSimple() throws Exception {
final String fileName = "SuppressionXpathRegressionIllegalInstantiationSimple.java";
final String fileName = "InputXpathIllegalInstantiationSimple.java";
final File fileToProcess = new File(getNonCompilablePath(fileName));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionIllegalInstantiationSimple']]"
+ "[@text='InputXpathIllegalInstantiationSimple']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='x']]/ASSIGN/EXPR",
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionIllegalInstantiationSimple']]"
+ "[./IDENT[@text='InputXpathIllegalInstantiationSimple']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/VARIABLE_DEF"
+ "[./IDENT[@text='x']]/ASSIGN/EXPR/LITERAL_NEW[./IDENT[@text='Boolean']]"
);
Expand All @@ -67,7 +67,7 @@ public void testSimple() throws Exception {

@Test
public void testAnonymous() throws Exception {
final String fileName = "SuppressionXpathRegressionIllegalInstantiationAnonymous.java";
final String fileName = "InputXpathIllegalInstantiationAnonymous.java";
final File fileToProcess = new File(getNonCompilablePath(fileName));

final DefaultConfiguration moduleConfig =
Expand All @@ -81,11 +81,11 @@ public void testAnonymous() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionIllegalInstantiationAnonymous']]"
+ "[@text='InputXpathIllegalInstantiationAnonymous']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Inner']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[./IDENT[@text='e']]/ASSIGN/EXPR",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionIllegalInstantiationAnonymous']]"
+ "[@text='InputXpathIllegalInstantiationAnonymous']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Inner']]/OBJBLOCK/METHOD_DEF"
+ "[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[./IDENT[@text='e']]"
+ "/ASSIGN/EXPR/LITERAL_NEW[./IDENT[@text='Integer']]"
Expand All @@ -97,7 +97,7 @@ public void testAnonymous() throws Exception {

@Test
public void testInterface() throws Exception {
final String fileName = "SuppressionXpathRegressionIllegalInstantiationInterface.java";
final String fileName = "InputXpathIllegalInstantiationInterface.java";
final File fileToProcess = new File(getNonCompilablePath(fileName));

final DefaultConfiguration moduleConfig =
Expand All @@ -111,12 +111,12 @@ public void testInterface() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionIllegalInstantiationInterface']]"
+ "[@text='InputXpathIllegalInstantiationInterface']]"
+ "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Inner']]/"
+ "OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/"
+ "VARIABLE_DEF[./IDENT[@text='s']]/ASSIGN/EXPR",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionIllegalInstantiationInterface']]"
+ "[@text='InputXpathIllegalInstantiationInterface']]"
+ "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Inner']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/VARIABLE_DEF"
+ "[./IDENT[@text='s']]/ASSIGN/EXPR/LITERAL_NEW[./IDENT[@text='String']]"
Expand Down
Expand Up @@ -41,7 +41,7 @@ protected String getCheckName() {
public void testOne() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPackageAnnotationOne.java"));
"InputXpathPackageAnnotationOne.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(PackageAnnotationCheck.class);
Expand All @@ -62,7 +62,7 @@ public void testOne() throws Exception {
public void testTwo() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPackageAnnotationTwo.java"));
"InputXpathPackageAnnotationTwo.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(PackageAnnotationCheck.class);
Expand Down
Expand Up @@ -38,9 +38,9 @@ protected String getCheckName() {
}

@Test
public void test1() throws Exception {
public void testWrongPackage() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath("SuppressionXpathRegression1.java"));
new File(getNonCompilablePath("InputXpathWrongPackage.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(PackageDeclarationCheck.class);
Expand All @@ -59,9 +59,9 @@ public void test1() throws Exception {
}

@Test
public void test2() throws Exception {
public void testMissingPackage() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath("SuppressionXpathRegression2.java"));
new File(getNonCompilablePath("InputXpathMissingPackage.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(PackageDeclarationCheck.class);
Expand All @@ -73,11 +73,11 @@ public void test2() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegression2']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathMissingPackage']]",
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegression2']]/MODIFIERS",
+ "[./IDENT[@text='InputXpathMissingPackage']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegression2']]/MODIFIERS/LITERAL_PUBLIC"
+ "[./IDENT[@text='InputXpathMissingPackage']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -42,7 +42,7 @@ protected String getCheckName() {
public void testOne() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPatternVariableName1.java"));
"InputXpathPatternVariableNameOne.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName1']]"
+ "[./IDENT[@text='InputXpathPatternVariableNameOne']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/"
+ "LITERAL_INSTANCEOF[./IDENT[@text='o1']]/PATTERN_VARIABLE_DEF/"
+ "IDENT[@text='STRING1']"
Expand All @@ -70,7 +70,7 @@ public void testOne() throws Exception {
public void testTwo() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPatternVariableName2.java"));
"InputXpathPatternVariableNameTwo.java"));

final String nonDefaultPattern = "^_[a-zA-Z0-9]*$";

Expand All @@ -85,7 +85,7 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName2']]"
+ "[./IDENT[@text='InputXpathPatternVariableNameTwo']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/"
+ "LITERAL_INSTANCEOF[./IDENT[@text='o1']]/"
+ "PATTERN_VARIABLE_DEF/IDENT[@text='s']"
Expand All @@ -99,7 +99,7 @@ public void testTwo() throws Exception {
public void testThree() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPatternVariableName3.java"));
"InputXpathPatternVariableNameThree.java"));

final String nonDefaultPattern = "^[a-z](_?[a-zA-Z0-9]+)*$";

Expand All @@ -114,7 +114,7 @@ public void testThree() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName3']]"
+ "[./IDENT[@text='InputXpathPatternVariableNameThree']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/"
+ "EXPR/LITERAL_INSTANCEOF[./IDENT[@text='o1']]/"
+ "PATTERN_VARIABLE_DEF/IDENT[@text='STR']"
Expand All @@ -128,7 +128,7 @@ public void testThree() throws Exception {
public void testFour() throws Exception {
final File fileToProcess =
new File(getNonCompilablePath(
"SuppressionXpathRegressionPatternVariableName4.java"));
"InputXpathPatternVariableNameFour.java"));

final String nonDefaultPattern = "^[a-z][_a-zA-Z0-9]{2,}$";

Expand All @@ -143,7 +143,7 @@ public void testFour() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName1']]"
+ "[./IDENT[@text='InputXpathPatternVariableNameFour']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/"
+ "LITERAL_INSTANCEOF[./IDENT[@text='o1']]/"
+ "PATTERN_VARIABLE_DEF/IDENT[@text='st']"
Expand Down
Expand Up @@ -39,9 +39,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testDefault() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRecordComponentName1.java"));
"InputXpathRecordComponentNameDefault.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='SuppressionXpathRecordComponentName1']]"
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='InputXpathRecordComponentNameDefault']]"
+ "/RECORD_COMPONENTS/RECORD_COMPONENT_DEF/IDENT[@text='_value']"
);

Expand All @@ -62,9 +62,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testFormat() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRecordComponentName2.java"));
"InputXpathRecordComponentNameFormat.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRecordComponentName2']]/OBJBLOCK"
+ "[./IDENT[@text='InputXpathRecordComponentNameFormat']]/OBJBLOCK"
+ "/RECORD_DEF[./IDENT[@text='MyRecord']]"
+ "/RECORD_COMPONENTS/RECORD_COMPONENT_DEF/IDENT[@text='otherValue']"
);
Expand Down
Expand Up @@ -38,9 +38,9 @@ protected String getCheckName() {
}

@Test
public void testOne() throws Exception {
public void testDefault() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRecordComponentNumber1.java"));
"InputXpathRecordComponentNumberDefault.java"));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber1']]",
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber1']]"
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='InputXpathRecordComponentNumberDefault']]",
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='InputXpathRecordComponentNumberDefault']]"
+ "/MODIFIERS",
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber1']]"
"/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='InputXpathRecordComponentNumberDefault']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
);

Expand All @@ -64,9 +64,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testCustomMax() throws Exception {
final File fileToProcess = new File(getNonCompilablePath(
"SuppressionXpathRecordComponentNumber2.java"));
"InputXpathRecordComponentNumberCustomMax.java"));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber2']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathRecordComponentNumberCustomMax']]"
+ "/OBJBLOCK/RECORD_DEF[./IDENT[@text='MyRecord']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber2']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathRecordComponentNumberCustomMax']]"
+ "/OBJBLOCK/RECORD_DEF[./IDENT[@text='MyRecord']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRecordComponentNumber2']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathRecordComponentNumberCustomMax']]"
+ "/OBJBLOCK/RECORD_DEF[./IDENT[@text='MyRecord']]/MODIFIERS"
+ "/LITERAL_PUBLIC"
);
Expand Down
Expand Up @@ -5,7 +5,7 @@
*
* default
*/
public record SuppressionXpathRegressionIllegalIdentifierNameTestOne
public record InputXpathIllegalIdentifierNameOne
(String string,
String yield, // warn
String otherString){
Expand Down
Expand Up @@ -5,7 +5,7 @@
*
* default
*/
public class SuppressionXpathRegressionIllegalIdentifierNameTestTwo {
public class InputXpathIllegalIdentifierNameTwo {
int foo(int yield) { // warn
return switch (yield) {
case 1 -> 2;
Expand Down
Expand Up @@ -2,7 +2,7 @@

package org.checkstyle.suppressionxpathfilter.illegalinstantiation;

public class SuppressionXpathRegressionIllegalInstantiationAnonymous {
public class InputXpathIllegalInstantiationAnonymous {
int b = 5; // ok
class Inner{
public void test() {
Expand Down
Expand Up @@ -2,7 +2,7 @@

package org.checkstyle.suppressionxpathfilter.illegalinstantiation;

public class SuppressionXpathRegressionIllegalInstantiationInterface {
public class InputXpathIllegalInstantiationInterface {
interface Inner {
default void test() {
Boolean x = new Boolean(true); // ok
Expand Down
Expand Up @@ -2,7 +2,7 @@

package org.checkstyle.suppressionxpathfilter.illegalinstantiation;

public class SuppressionXpathRegressionIllegalInstantiationSimple {
public class InputXpathIllegalInstantiationSimple {
int b = 5; // ok
public void test() {
Boolean x = new Boolean(true); // warn
Expand Down
Expand Up @@ -3,6 +3,6 @@
@Deprecated
package com.puppycrawl.tools.checkstyle.checks.annotation.packageannotation; // warn

public class SuppressionXpathRegressionPackageAnnotationOne {
public class InputXpathPackageAnnotationOne {

}
Expand Up @@ -5,6 +5,6 @@

import javax.annotation.Generated;

public class SuppressionXpathRegressionPackageAnnotationOne {
public class InputXpathPackageAnnotationTwo {

}
@@ -1,5 +1,5 @@
// non-compiled with javac: missing package. Used for Testing purpose.
// package is missing.
public class SuppressionXpathRegression2 { // warn
public class InputXpathMissingPackage { // warn
// code
}

0 comments on commit 101e623

Please sign in to comment.