From 8bdf602dcb41a1b8df52a9ecb183ee41f842c9ef Mon Sep 17 00:00:00 2001 From: Sam Snyder Date: Wed, 13 Mar 2024 20:34:22 -0700 Subject: [PATCH 1/3] Include AddDependency on mockito-junit-jupiter as part of the junit 4 to 5 migration --- src/main/resources/META-INF/rewrite/junit5.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/resources/META-INF/rewrite/junit5.yml b/src/main/resources/META-INF/rewrite/junit5.yml index 942a17c5b..c89943a4e 100755 --- a/src/main/resources/META-INF/rewrite/junit5.yml +++ b/src/main/resources/META-INF/rewrite/junit5.yml @@ -151,6 +151,13 @@ recipeList: artifactId: "*" newVersion: 3.x overrideManagedVersion: false + - org.openrewrite.java.dependencies.AddDependency: + groupId: org.mockito + artifactId: mockito-junit-jupiter + version: 3.x + onlyIfUsing: org.mockito..* + acceptTransitive: true + scope: test - org.openrewrite.maven.UpgradePluginVersion: groupId: org.apache.maven.plugins artifactId: maven-surefire-plugin From 1433a6dc98f3218a76ec23e6ce5666ec1c796f7c Mon Sep 17 00:00:00 2001 From: Sam Snyder Date: Thu, 14 Mar 2024 01:57:04 -0700 Subject: [PATCH 2/3] Update Maven surefire plugin to a version which requires no additional configuration to run JUnit 5 tests. Remove redundant/unnecessary AddDependency operations. --- .../resources/META-INF/rewrite/junit5.yml | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/main/resources/META-INF/rewrite/junit5.yml b/src/main/resources/META-INF/rewrite/junit5.yml index c89943a4e..99f3aa9a2 100755 --- a/src/main/resources/META-INF/rewrite/junit5.yml +++ b/src/main/resources/META-INF/rewrite/junit5.yml @@ -117,27 +117,7 @@ recipeList: groupId: org.junit.jupiter artifactId: junit-jupiter version: 5.x - onlyIfUsing: org.junit.Test - scope: test - - org.openrewrite.java.dependencies.AddDependency: - groupId: org.junit.jupiter - artifactId: junit-jupiter - version: 5.x - onlyIfUsing: org.junit.jupiter.api.Test - acceptTransitive: true - scope: test - - org.openrewrite.java.dependencies.AddDependency: - groupId: org.junit.jupiter - artifactId: junit-jupiter-api - version: 5.x - onlyIfUsing: org.junit.Test - scope: test - - org.openrewrite.java.dependencies.AddDependency: - groupId: org.junit.jupiter - artifactId: junit-jupiter-api - version: 5.x - onlyIfUsing: org.junit.jupiter.api.Test - acceptTransitive: true + onlyIfUsing: org.junit..* scope: test - org.openrewrite.java.dependencies.AddDependency: groupId: org.junit.jupiter @@ -161,11 +141,11 @@ recipeList: - org.openrewrite.maven.UpgradePluginVersion: groupId: org.apache.maven.plugins artifactId: maven-surefire-plugin - newVersion: 2.22.x + newVersion: 3.1.x - org.openrewrite.maven.UpgradePluginVersion: groupId: org.apache.maven.plugins artifactId: maven-failsafe-plugin - newVersion: 2.22.x + newVersion: 3.1.x --- type: specs.openrewrite.org/v1beta/recipe From bcb4449f913f43ca2820ce18214d4399f7617833 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 14 Mar 2024 10:04:09 +0000 Subject: [PATCH 3/3] 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/datafaker/JavaFakerToDataFakerTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/openrewrite/java/testing/datafaker/JavaFakerToDataFakerTest.java b/src/test/java/org/openrewrite/java/testing/datafaker/JavaFakerToDataFakerTest.java index 0701a3084..aa3d85f7f 100644 --- a/src/test/java/org/openrewrite/java/testing/datafaker/JavaFakerToDataFakerTest.java +++ b/src/test/java/org/openrewrite/java/testing/datafaker/JavaFakerToDataFakerTest.java @@ -16,6 +16,7 @@ package org.openrewrite.java.testing.datafaker; import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -30,6 +31,7 @@ public void defaults(RecipeSpec spec) { .parser(JavaParser.fromJavaVersion().classpath("javafaker", "datafaker")); } + @DocumentExample @Test void javaFakerToDataFaker() { rewriteRun(