From 7ed802978a299c58ec866aed2b1b1bbe1cfc473b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Schn=C3=A9ider?= Date: Wed, 12 Jun 2024 18:12:16 +0000 Subject: [PATCH] refactor: Add a blank line around fields with annotations Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.BlankLinesAroundFieldsWithAnnotations?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../openrewrite/java/testing/junit5/LifecycleNonPrivate.java | 1 + .../java/testing/junit5/ParameterizedRunnerToParameterized.java | 2 ++ .../java/testing/hamcrest/MigrateHamcrestToAssertJTest.java | 1 + 3 files changed, 4 insertions(+) diff --git a/src/main/java/org/openrewrite/java/testing/junit5/LifecycleNonPrivate.java b/src/main/java/org/openrewrite/java/testing/junit5/LifecycleNonPrivate.java index 60f4881fb..273362d04 100644 --- a/src/main/java/org/openrewrite/java/testing/junit5/LifecycleNonPrivate.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/LifecycleNonPrivate.java @@ -39,6 +39,7 @@ public class LifecycleNonPrivate extends Recipe { "org.junit.jupiter.api.AfterEach", "org.junit.jupiter.api.BeforeAll", "org.junit.jupiter.api.BeforeEach"); + @SuppressWarnings("unchecked") private static final TreeVisitor PRECONDITION = Preconditions.or(ANNOTATION_TYPES.stream().map(r -> new UsesType<>(r, false)).toArray(UsesType[]::new)); diff --git a/src/main/java/org/openrewrite/java/testing/junit5/ParameterizedRunnerToParameterized.java b/src/main/java/org/openrewrite/java/testing/junit5/ParameterizedRunnerToParameterized.java index 1a30b6cd1..fa8d51a3e 100644 --- a/src/main/java/org/openrewrite/java/testing/junit5/ParameterizedRunnerToParameterized.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/ParameterizedRunnerToParameterized.java @@ -142,8 +142,10 @@ private static class ParameterizedRunnerToParameterizedTestsVisitor extends Java private final J.ClassDeclaration scope; private final String initMethodName; private final List parameterizedTestMethodParameters; + @Nullable private final List parameterizedTestAnnotationParameters; + private final String initStatementParamString; private final JavaTemplate parameterizedTestTemplate; diff --git a/src/test/java/org/openrewrite/java/testing/hamcrest/MigrateHamcrestToAssertJTest.java b/src/test/java/org/openrewrite/java/testing/hamcrest/MigrateHamcrestToAssertJTest.java index bc3c30f62..685f993df 100644 --- a/src/test/java/org/openrewrite/java/testing/hamcrest/MigrateHamcrestToAssertJTest.java +++ b/src/test/java/org/openrewrite/java/testing/hamcrest/MigrateHamcrestToAssertJTest.java @@ -522,6 +522,7 @@ void test() { } } """; + @Language("java") private static final String JAVA_AFTER = """ import org.junit.jupiter.api.Test;