Skip to content

Commit e745664

Browse files
committed
Issue #41: updated upperEllTest to use AbstractTestRecipeSupport
1 parent faeab1d commit e745664

File tree

10 files changed

+113
-156
lines changed

10 files changed

+113
-156
lines changed

src/test/java/org/checkstyle/autofix/recipe/UpperEllTest.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,42 @@
1717

1818
package org.checkstyle.autofix.recipe;
1919

20-
import java.io.IOException;
21-
import java.nio.file.Path;
2220
import java.util.List;
2321

24-
import org.checkstyle.autofix.parser.CheckstyleReportParser;
2522
import org.checkstyle.autofix.parser.CheckstyleViolation;
2623
import org.junit.jupiter.api.Test;
2724
import org.openrewrite.Recipe;
2825

29-
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
30-
31-
public class UpperEllTest extends AbstractRecipeTest {
26+
public class UpperEllTest extends AbstractRecipeTestSupport {
3227

3328
@Override
34-
protected Recipe getRecipe() {
35-
final String reportPath = "src/test/resources/org/checkstyle/autofix/recipe/upperell"
36-
+ "/report.xml";
29+
protected String getSubpackage() {
30+
return "upperell";
31+
}
3732

38-
final List<CheckstyleViolation> violations =
39-
CheckstyleReportParser.parse(Path.of(reportPath));
40-
return new UpperEll(violations);
33+
@Override
34+
protected String getCheckName() {
35+
return "com.puppycrawl.tools.checkstyle.checks.UpperEllCheck";
4136
}
4237

43-
@Test
44-
void hexOctalLiteralTest() throws IOException, CheckstyleException {
45-
testRecipe("upperell", "HexOctalLiteral");
38+
@Override
39+
protected Recipe createRecipe(List<CheckstyleViolation> violations) {
40+
41+
return new UpperEll(violations);
4642
}
4743

4844
@Test
49-
void complexLongLiterals() throws IOException, CheckstyleException {
50-
testRecipe("upperell", "ComplexLongLiterals");
45+
void hexOctalLiteral() throws Exception {
46+
verify("HexOctalLiteral");
5147
}
5248

5349
@Test
54-
void stringAndCommentTest() throws IOException, CheckstyleException {
55-
testRecipe("upperell", "StringAndComments");
50+
void complexLongLiterals() throws Exception {
51+
verify("ComplexLongLiterals");
5652
}
5753

5854
@Test
59-
void symbolicLiteralTest() throws IOException, CheckstyleException {
60-
testRecipe("upperell", "SymbolicLiterals");
55+
void stringAndComments() throws Exception {
56+
verify("StringAndComments");
6157
}
6258
}

src/test/resources/org/checkstyle/autofix/recipe/upperell/complexlongliterals/InputComplexLongLiterals.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
4+
<property name="checks" value="UpperEll"/>
5+
<property name="query" value="//NUM_LONG[@text='9223372036854775807l' or
6+
@text='9223372036854775808l']"/>
7+
</module>
8+
<module name="TreeWalker">
9+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
10+
</module>
11+
</module>
12+
13+
*/
14+
115
package org.checkstyle.autofix.recipe.upperell.complexlongliterals;
216

317
public class InputComplexLongLiterals {
418
private long withUnderscores = 1_000_000l;
519
private long multipleUnderscores = 1_234_567_890l;
620

7-
private long maxLong = 9223372036854775807l;
8-
private long minLong = -9223372036854775808l;
21+
private long maxLong = 9223372036854775807l; //suppressed violation
22+
private long minLong = -9223372036854775808l; //suppressed violation
923

1024
private Long nullLong = null;
1125
private Long simpleLong = 1234l;

src/test/resources/org/checkstyle/autofix/recipe/upperell/complexlongliterals/OutputComplexLongLiterals.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
4+
<property name="checks" value="UpperEll"/>
5+
<property name="query" value="//NUM_LONG[@text='9223372036854775807l' or
6+
@text='9223372036854775808l']"/>
7+
</module>
8+
<module name="TreeWalker">
9+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
10+
</module>
11+
</module>
12+
13+
*/
14+
115
package org.checkstyle.autofix.recipe.upperell.complexlongliterals;
216

317
public class OutputComplexLongLiterals {
418
private long withUnderscores = 1_000_000L;
519
private long multipleUnderscores = 1_234_567_890L;
620

7-
private long maxLong = 9223372036854775807L;
8-
private long minLong = -9223372036854775808L;
21+
private long maxLong = 9223372036854775807l; //suppressed violation
22+
private long minLong = -9223372036854775808l; //suppressed violation
923

1024
private Long nullLong = null;
1125
private Long simpleLong = 1234L;

src/test/resources/org/checkstyle/autofix/recipe/upperell/hexoctalliteral/InputHexOctalLiteral.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
4+
<property name="checks" value="UpperEll"/>
5+
<property name="query" value="//NUM_LONG[@text='0xDEADBEFl' or @text='01234l']"/>
6+
</module>
7+
<module name="TreeWalker">
8+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
9+
</module>
10+
</module>
11+
12+
*/
13+
114
package org.checkstyle.autofix.recipe.upperell.hexoctalliteral;
215

316
public class InputHexOctalLiteral {
@@ -9,7 +22,7 @@ public class InputHexOctalLiteral {
922

1023
public void calculateValues() {
1124
long hexResult = 0xDEADBEEFl + 0xDEADBEFl; //suppressed violation for 0xDEADBEFl
12-
long octalResult = 01234l + 0xDEADBEEFl; //suppressed violation for 0xDEADBEFl
25+
long octalResult = 01234l + 0xDEADBEEFl; //suppressed violation for 01234l
1326
long binaryResult = 0b11110000l;
1427
}
1528
}

src/test/resources/org/checkstyle/autofix/recipe/upperell/hexoctalliteral/OutputHexOctalLiteral.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="com.puppycrawl.tools.checkstyle.filters.SuppressionXpathSingleFilter">
4+
<property name="checks" value="UpperEll"/>
5+
<property name="query" value="//NUM_LONG[@text='0xDEADBEFl' or @text='01234l']"/>
6+
</module>
7+
<module name="TreeWalker">
8+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
9+
</module>
10+
</module>
11+
12+
*/
13+
114
package org.checkstyle.autofix.recipe.upperell.hexoctalliteral;
215

316
public class OutputHexOctalLiteral {
@@ -9,7 +22,7 @@ public class OutputHexOctalLiteral {
922

1023
public void calculateValues() {
1124
long hexResult = 0xDEADBEEFL + 0xDEADBEFl; //suppressed violation for 0xDEADBEFl
12-
long octalResult = 01234L + 0xDEADBEEFl; //suppressed violation for 0xDEADBEFl
25+
long octalResult = 01234l + 0xDEADBEEFL; //suppressed violation for 01234l
1326
long binaryResult = 0b11110000L;
1427
}
1528
}

src/test/resources/org/checkstyle/autofix/recipe/upperell/report.xml

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/test/resources/org/checkstyle/autofix/recipe/upperell/stringandcomments/InputStringAndComments.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="TreeWalker">
4+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
5+
</module>
6+
</module>
7+
8+
*/
9+
110
package org.checkstyle.autofix.recipe.upperell.stringandcomments;
211

312
public class InputStringAndComments {

src/test/resources/org/checkstyle/autofix/recipe/upperell/stringandcomments/OutputStringAndComments.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="TreeWalker">
4+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
5+
</module>
6+
</module>
7+
8+
*/
9+
110
package org.checkstyle.autofix.recipe.upperell.stringandcomments;
211

312
public class OutputStringAndComments {

src/test/resources/org/checkstyle/autofix/recipe/upperell/symbolicliterals/InputSymbolicLiterals.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="TreeWalker">
4+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
5+
</module>
6+
</module>
7+
8+
*/
9+
110
package org.checkstyle.autofix.recipe.upperell.symbolicliterals;
211

312
public class InputSymbolicLiterals {

src/test/resources/org/checkstyle/autofix/recipe/upperell/symbolicliterals/OutputSymbolicLiterals.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="TreeWalker">
4+
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
5+
</module>
6+
</module>
7+
8+
*/
9+
110
package org.checkstyle.autofix.recipe.upperell.symbolicliterals;
211

312
public class OutputSymbolicLiterals {

0 commit comments

Comments
 (0)