Skip to content

Commit

Permalink
Issue #14715: Enforced new naming convention in IT area Nine
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and rnveach committed Apr 7, 2024
1 parent e30260d commit 571e547
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 79 deletions.
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("SuppressionXpathRegressionEmptyLineSeparator1.java")
getPath("InputXpathEmptyLineSeparatorOne.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -61,7 +61,7 @@ public void testOne() throws Exception {
@Test
public void testTwo() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEmptyLineSeparator2.java")
getPath("InputXpathEmptyLineSeparatorTwo.java")
);

final DefaultConfiguration moduleConfig =
Expand All @@ -83,7 +83,7 @@ public void testTwo() throws Exception {
@Test
public void testThree() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEmptyLineSeparator3.java")
getPath("InputXpathEmptyLineSeparatorThree.java")
);

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator3']]"
+ "[./IDENT[@text='InputXpathEmptyLineSeparatorThree']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator3']]"
+ "[./IDENT[@text='InputXpathEmptyLineSeparatorThree']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]"
+ "/MODIFIERS",

"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator3']]"
+ "[./IDENT[@text='InputXpathEmptyLineSeparatorThree']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
);
Expand All @@ -117,7 +117,7 @@ public void testThree() throws Exception {
@Test
public void testFour() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEmptyLineSeparator4.java")
getPath("InputXpathEmptyLineSeparatorFour.java")
);

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator4']]"
+ "[./IDENT[@text='InputXpathEmptyLineSeparatorFour']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]/SLIST/RCURLY"
);

Expand All @@ -141,7 +141,7 @@ public void testFour() throws Exception {
@Test
public void testFive() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEmptyLineSeparator5.java")
getPath("InputXpathEmptyLineSeparatorFive.java")
);

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator5']]"
+ "[./IDENT[@text='InputXpathEmptyLineSeparatorFive']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]/SLIST/LITERAL_TRY/SLIST"
+ "/SINGLE_LINE_COMMENT/COMMENT_CONTENT[@text=' warn\\n']"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected String getCheckName() {
@Test
public void testEquals() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEqualsAvoidNull.java"));
getPath("InputXpathEqualsAvoidNull.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(clazz);

Expand All @@ -51,10 +51,10 @@ public void testEquals() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsAvoidNull']]"
+ "[@text='InputXpathEqualsAvoidNull']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/EXPR",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsAvoidNull']]"
+ "[@text='InputXpathEqualsAvoidNull']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/EXPR/METHOD_CALL");

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
Expand All @@ -63,7 +63,7 @@ public void testEquals() throws Exception {
@Test
public void testEqualsIgnoreCase() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEqualsAvoidNullIgnoreCase.java"));
getPath("InputXpathEqualsAvoidNullIgnoreCase.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(clazz);

Expand All @@ -74,10 +74,10 @@ public void testEqualsIgnoreCase() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsAvoidNullIgnoreCase']]"
+ "[@text='InputXpathEqualsAvoidNullIgnoreCase']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/EXPR",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsAvoidNullIgnoreCase']]"
+ "[@text='InputXpathEqualsAvoidNullIgnoreCase']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/EXPR/METHOD_CALL");

runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected String getCheckName() {
@Test
public void testEqualsOnly() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEqualsHashCode1.java"));
getPath("InputXpathEqualsHashCodeEqualsOnly.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(EqualsHashCodeCheck.class);

Expand All @@ -48,13 +48,13 @@ public void testEqualsOnly() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode1']]"
+ "[@text='InputXpathEqualsHashCodeEqualsOnly']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='equals']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode1']]/OBJBLOCK/"
+ "[@text='InputXpathEqualsHashCodeEqualsOnly']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='equals']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode1']]/OBJBLOCK/"
+ "[@text='InputXpathEqualsHashCodeEqualsOnly']]/OBJBLOCK/"
+ "METHOD_DEF[./IDENT[@text='equals']]/MODIFIERS/LITERAL_PUBLIC"
);

Expand All @@ -64,7 +64,7 @@ public void testEqualsOnly() throws Exception {
@Test
public void testHashCodeOnly() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEqualsHashCode2.java"));
getPath("InputXpathEqualsHashCodeHashCodeOnly.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(EqualsHashCodeCheck.class);

Expand All @@ -75,13 +75,13 @@ public void testHashCodeOnly() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode2']]"
+ "[@text='InputXpathEqualsHashCodeHashCodeOnly']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='hashCode']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode2']]"
+ "[@text='InputXpathEqualsHashCodeHashCodeOnly']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='hashCode']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCode2']]"
+ "[@text='InputXpathEqualsHashCodeHashCodeOnly']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='hashCode']]/MODIFIERS/LITERAL_PUBLIC"
);

Expand All @@ -91,7 +91,7 @@ public void testHashCodeOnly() throws Exception {
@Test
public void testNestedCase() throws Exception {
final File fileToProcess = new File(
getPath("SuppressionXpathRegressionEqualsHashCodeNestedCase.java"));
getPath("InputXpathEqualsHashCodeNestedCase.java"));

final DefaultConfiguration moduleConfig = createModuleConfig(EqualsHashCodeCheck.class);

Expand All @@ -102,15 +102,15 @@ public void testNestedCase() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCodeNestedCase']]"
+ "[@text='InputXpathEqualsHashCodeNestedCase']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='innerClass']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='equals']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCodeNestedCase']]"
+ "[@text='InputXpathEqualsHashCodeNestedCase']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='innerClass']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='equals']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionEqualsHashCodeNestedCase']]"
+ "[@text='InputXpathEqualsHashCodeNestedCase']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='innerClass']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='equals']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
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 testPrimitiveType() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionExplicitInitializationOne.java"));
new File(getPath("InputXpathExplicitInitializationPrimitiveType.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionExplicitInitializationOne']]"
+ "[./IDENT[@text='InputXpathExplicitInitializationPrimitiveType']]"
+ "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='a']"
);

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

@Test
public void testTwo() throws Exception {
public void testObjectType() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionExplicitInitializationTwo.java"));
new File(getPath("InputXpathExplicitInitializationObjectType.java"));

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

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF"
+ "[./IDENT[@text='SuppressionXpathRegressionExplicitInitializationTwo']]"
+ "[./IDENT[@text='InputXpathExplicitInitializationObjectType']]"
+ "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='bar']"
);

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 testFallThrough() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionFallThroughOne.java"));
new File(getPath("InputXpathFallThrough.java"));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionFallThroughOne']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathFallThrough']]"
+ "/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP["
+ "./LITERAL_CASE/EXPR/NUM_INT[@text='2']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionFallThroughOne']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathFallThrough']]"
+ "/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP/LITERAL_CASE"
);
Expand All @@ -65,9 +65,9 @@ public void testOne() throws Exception {
}

@Test
public void testTwo() throws Exception {
public void testDefaultCase() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionFallThroughTwo.java"));
new File(getPath("InputXpathFallThroughDefaultCase.java"));

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

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionFallThroughTwo']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathFallThroughDefaultCase']]"
+ "/OBJBLOCK/METHOD_DEF["
+ "./IDENT[@text='methodFallThruCustomWords']]/SLIST/LITERAL_WHILE/SLIST"
+ "/LITERAL_SWITCH/CASE_GROUP[./SLIST/EXPR/POST_INC/IDENT[@text='i']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionFallThroughTwo']]"
"/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathFallThroughDefaultCase']]"
+ "/OBJBLOCK/METHOD_DEF["
+ "./IDENT[@text='methodFallThruCustomWords']]/SLIST/LITERAL_WHILE/SLIST"
+ "/LITERAL_SWITCH/CASE_GROUP/LITERAL_DEFAULT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ protected String getCheckName() {
}

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

final DefaultConfiguration moduleConfig =
createModuleConfig(FinalClassCheck.class);

final String[] expectedViolation = {
"3:1: " + getCheckMessage(FinalClassCheck.class,
FinalClassCheck.MSG_KEY, "SuppressionXpathRegressionFinalClass1"),
FinalClassCheck.MSG_KEY, "InputXpathFinalClassDefault"),
};

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

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

@Test
public void testTwo() throws Exception {
public void testInnerClass() throws Exception {
final File fileToProcess = new File(getPath(
"SuppressionXpathRegressionFinalClass2.java"));
"InputXpathFinalClassInnerClass.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(FinalClassCheck.class);
Expand All @@ -77,13 +77,13 @@ public void testTwo() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalClass2']]"
+ "@text='InputXpathFinalClassInnerClass']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Test']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalClass2']]"
+ "@text='InputXpathFinalClassInnerClass']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Test']]/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionFinalClass2']]"
+ "@text='InputXpathFinalClassInnerClass']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Test']]/LITERAL_CLASS"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.IOException;

public class SuppressionXpathRegressionEmptyLineSeparator5 {
public class InputXpathEmptyLineSeparatorFive {

int foo1() throws Exception {
int a = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package org.checkstyle.suppressionxpathfilter.emptylineseparator;

class SuppressionXpathRegressionEmptyLineSeparator4 {
class InputXpathEmptyLineSeparatorFour {
public static final int FOO_CONST = 1;

public void foo() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
///////////////////////////////////////////////////
package org.checkstyle.suppressionxpathfilter.emptylineseparator;
import java.io.*;
class SuppressionXpathRegressionEmptyLineSeparator3 {
class InputXpathEmptyLineSeparatorThree {
public static final int FOO_CONST = 1;
public void foo() {}
public void foo1() {} // warn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.equalsavoidnull;

public class SuppressionXpathRegressionEqualsAvoidNull {
public class InputXpathEqualsAvoidNull {
public void test() {
String nullString = null;
nullString.equals("Another string"); //warn
Expand Down

0 comments on commit 571e547

Please sign in to comment.