From db1f9191cb8d322936b58af94cbf6568d5f0d066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Schn=C3=A9ider?= Date: Thu, 21 Mar 2024 00:03:14 +0000 Subject: [PATCH] refactor: OpenRewrite best practices Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.recipes.OpenRewriteBestPractices?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../java/testing/junit5/GradleUseJunitJupiter.java | 2 +- .../java/testing/junit5/GradleUseJunitJupiterTest.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiter.java b/src/main/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiter.java index 49eee80d6..995408803 100644 --- a/src/main/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiter.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiter.java @@ -143,7 +143,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu private static class AddUseJUnitPlatform extends GroovyIsoVisitor { @Override - public G.CompilationUnit visitCompilationUnit(G.CompilationUnit cu, ExecutionContext executionContext) { + public G.CompilationUnit visitCompilationUnit(G.CompilationUnit cu, ExecutionContext ctx) { G.CompilationUnit template = GradleParser.builder() .build() .parse("plugins {\n" + diff --git a/src/test/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiterTest.java b/src/test/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiterTest.java index 80610f3c8..6fc646912 100644 --- a/src/test/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiterTest.java +++ b/src/test/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiterTest.java @@ -16,13 +16,14 @@ package org.openrewrite.java.testing.junit5; import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; import static org.openrewrite.gradle.Assertions.buildGradle; import static org.openrewrite.gradle.toolingapi.Assertions.withToolingApi; -public class GradleUseJunitJupiterTest implements RewriteTest { +class GradleUseJunitJupiterTest implements RewriteTest { @Override public void defaults(RecipeSpec spec) { @@ -30,6 +31,7 @@ public void defaults(RecipeSpec spec) { .beforeRecipe(withToolingApi()); } + @DocumentExample @Test void addWhenMissing() { rewriteRun( @@ -59,7 +61,7 @@ void addWhenMissing() { } @Test - void testDsl() { + void dsl() { rewriteRun( //language=groovy buildGradle( @@ -83,7 +85,7 @@ void testDsl() { } @Test - void testDslAlreadyExists() { + void dslAlreadyExists() { rewriteRun( //language=groovy buildGradle(