diff --git a/config/suppressions.xml b/config/suppressions.xml index c5dfa13..1b6c9af 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -8,4 +8,5 @@ + diff --git a/src/test/java/org/checkstyle/autofix/InputClassRenamer.java b/src/test/java/org/checkstyle/autofix/InputClassRenamer.java index 9b2bef7..f32c7a0 100644 --- a/src/test/java/org/checkstyle/autofix/InputClassRenamer.java +++ b/src/test/java/org/checkstyle/autofix/InputClassRenamer.java @@ -44,14 +44,9 @@ public TreeVisitor getVisitor() { return new ClassRenameVisitor(); } - /** - * A visitor that traverse Java AST nodes and renames classes starting with "Input" to "Output". - */ private static final class ClassRenameVisitor extends JavaIsoVisitor { - /** The prefix to match in class names. */ private static final String FROM_PREFIX = "Input"; - /** The prefix to replace with in class names. */ private static final String TO_PREFIX = "Output"; @Override @@ -82,13 +77,6 @@ public J.NewClass visitNewClass(J.NewClass constructorNode, return result; } - /** - * Checks if a given class name starts with the FROM_PREFIX - * and returns the renamed version with TO_PREFIX. - * - * @param originalName The original class name. - * @return The new class name with TO_PREFIX if matched, otherwise null. - */ private String renameIfMatch(String originalName) { final String result; if (originalName.startsWith(FROM_PREFIX)) { diff --git a/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTest.java b/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTest.java index 5d1bea9..27bc248 100644 --- a/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTest.java +++ b/src/test/java/org/checkstyle/autofix/recipe/AbstractRecipeTest.java @@ -28,47 +28,18 @@ import org.openrewrite.Recipe; import org.openrewrite.test.RewriteTest; -/** - * Base test class for recipe testing that provides common functionality - * for reading test files and executing recipe tests with preprocessing. - */ public abstract class AbstractRecipeTest implements RewriteTest { private static final String BASE_TEST_RESOURCES_PATH = "src/test/resources/org" + "/checkstyle/autofix/recipe/"; - /** - * Creates a preprocessing recipe that normalizes class names from InputXxx to OutputXxx. - * This allows test files to have descriptive names while maintaining consistent class names. - * - * @return the preprocessing recipe - */ private Recipe createPreprocessingRecipe() { return new InputClassRenamer(); } - /** - * Creates the main recipe that should be tested. - * Subclasses must implement this method to provide their specific recipe. - * - * @return the main recipe to test - */ protected abstract Recipe getRecipe(); - /** - * Tests a recipe with the given recipe path and test case name. - * Expects input and output files to follow the naming convention: - * - Input: {recipePath}/{testCaseName}/Input{testCaseName}.java - * - Output: {recipePath}/{testCaseName}/Output{testCaseName}.java - * The method automatically applies preprocessing to normalize class names - * before running the main recipe. - * - * @param recipePath the recipe-specific path. - * @param testCaseName the name of the test case (should match directory and file names) - * @throws IOException if files cannot be read - */ - protected void testRecipe(String recipePath, String testCaseName) - throws IOException { + protected void testRecipe(String recipePath, String testCaseName) throws IOException { final String testCaseDir = testCaseName.toLowerCase(); final String inputFileName = "Input" + testCaseName + ".java"; final String outputFileName = "Output" + testCaseName + ".java";