Skip to content

Commit 3a1c6b4

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

File tree

11 files changed

+111
-155
lines changed

11 files changed

+111
-155
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public abstract class AbstractRecipeTestSupport extends AbstractXmlTestSupport
4545

4646
protected abstract String getSubpackage();
4747

48-
protected abstract String getCheckName();
49-
5048
protected abstract Recipe createRecipe(List<CheckstyleViolation> violations);
5149

5250
@Override

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,43 @@
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;
26+
public class UpperEllTest extends AbstractRecipeTestSupport {
3027

31-
public class UpperEllTest extends AbstractRecipeTest {
28+
@Override
29+
protected String getSubpackage() {
30+
return "upperell";
31+
}
3232

3333
@Override
34-
protected Recipe getRecipe() {
35-
final String reportPath = "src/test/resources/org/checkstyle/autofix/recipe/upperell"
36-
+ "/report.xml";
34+
protected Recipe createRecipe(List<CheckstyleViolation> violations) {
3735

38-
final List<CheckstyleViolation> violations =
39-
CheckstyleReportParser.parse(Path.of(reportPath));
4036
return new UpperEll(violations);
4137
}
4238

4339
@Test
44-
void hexOctalLiteralTest() throws IOException, CheckstyleException {
45-
testRecipe("upperell", "HexOctalLiteral");
40+
void hexOctalLiteral() throws Exception {
41+
verify("HexOctalLiteral");
4642
}
4743

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

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

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

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 {

0 commit comments

Comments
 (0)