diff --git a/src/main/resources/META-INF/rewrite/mockito.yml b/src/main/resources/META-INF/rewrite/mockito.yml
index 18d8382b4..49a5b193a 100644
--- a/src/main/resources/META-INF/rewrite/mockito.yml
+++ b/src/main/resources/META-INF/rewrite/mockito.yml
@@ -43,6 +43,10 @@ recipeList:
groupId: org.mockito
artifactId: "*"
newVersion: 5.x
+ - org.openrewrite.java.dependencies.UpgradeDependencyVersion:
+ groupId: net.bytebuddy
+ artifactId: byte-buddy*
+ newVersion: 1.15.x
- org.openrewrite.maven.RemoveDuplicateDependencies
---
@@ -59,6 +63,10 @@ recipeList:
groupId: org.mockito
artifactId: "*"
newVersion: 4.x
+ - org.openrewrite.java.dependencies.UpgradeDependencyVersion:
+ groupId: net.bytebuddy
+ artifactId: byte-buddy*
+ newVersion: 1.12.19
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.mockito.Mockito1to3Migration
@@ -143,8 +151,8 @@ recipeList:
- org.openrewrite.java.testing.mockito.CleanupMockitoImports
- org.openrewrite.java.testing.mockito.MockUtilsToStatic
- org.openrewrite.java.testing.junit5.MockitoJUnitToMockitoExtension
-# https://github.com/openrewrite/rewrite-testing-frameworks/issues/360
-# - org.openrewrite.java.testing.mockito.ReplacePowerMockito
+ # https://github.com/openrewrite/rewrite-testing-frameworks/issues/360
+ # - org.openrewrite.java.testing.mockito.ReplacePowerMockito
- org.openrewrite.java.testing.mockito.RetainStrictnessWarn
- org.openrewrite.java.dependencies.AddDependency:
groupId: org.mockito
@@ -160,3 +168,7 @@ recipeList:
oldGroupId: org.mockito
oldArtifactId: mockito-all
newArtifactId: mockito-core
+ - org.openrewrite.java.dependencies.UpgradeDependencyVersion:
+ groupId: net.bytebuddy
+ artifactId: byte-buddy*
+ newVersion: 1.11.13
diff --git a/src/test/java/org/openrewrite/java/testing/mockito/MockitoInlineToCoreTest.java b/src/test/java/org/openrewrite/java/testing/mockito/MockitoInlineToCoreTest.java
index a7bdb1998..7e68ccb00 100644
--- a/src/test/java/org/openrewrite/java/testing/mockito/MockitoInlineToCoreTest.java
+++ b/src/test/java/org/openrewrite/java/testing/mockito/MockitoInlineToCoreTest.java
@@ -16,6 +16,7 @@
package org.openrewrite.java.testing.mockito;
import org.junit.jupiter.api.Test;
+import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;
@@ -29,6 +30,7 @@ public void defaults(RecipeSpec spec) {
spec.recipeFromResources("org.openrewrite.java.testing.mockito.Mockito1to5Migration");
}
+ @DocumentExample
@Test
void inlineToCore() {
rewriteRun(
@@ -50,25 +52,22 @@ void inlineToCore() {
""",
- sourceSpecs -> sourceSpecs.after(after -> {
- String version = Pattern.compile("(5.+)").matcher(after).results().reduce((a, b) -> b).orElseThrow().group(1);
- return """
-
- 4.0.0
- com.example
- demo
- 0.0.1-SNAPSHOT
-
-
- org.mockito
- mockito-core
- %s
- test
-
-
-
- """.formatted(version);
- })
+ spec -> spec.after(after -> """
+
+ 4.0.0
+ com.example
+ demo
+ 0.0.1-SNAPSHOT
+
+
+ org.mockito
+ mockito-core
+ %s
+ test
+
+
+
+ """.formatted(Pattern.compile("(5.+)").matcher(after).results().findFirst().orElseThrow().group(1)))
)
);
}
@@ -100,25 +99,77 @@ void noDuplicates() {
""",
- sourceSpecs -> sourceSpecs.after(after -> {
- String version = Pattern.compile("(5.+)").matcher(after).results().reduce((a, b) -> b).orElseThrow().group(1);
- return """
-
- 4.0.0
- com.example
- demo
- 0.0.1-SNAPSHOT
-
-
- org.mockito
- mockito-core
- %s
- test
-
-
-
- """.formatted(version);
- })
+ spec -> spec.after(after -> """
+
+ 4.0.0
+ com.example
+ demo
+ 0.0.1-SNAPSHOT
+
+
+ org.mockito
+ mockito-core
+ %s
+ test
+
+
+
+ """.formatted(Pattern.compile("(5.+)").matcher(after).results().findFirst().orElseThrow().group(1)))
+ )
+ );
+ }
+
+ @Test
+ void shouldUpdateByteBuddy() {
+ rewriteRun(
+ //language=xml
+ pomXml(
+ """
+
+ 4.0.0
+ com.example
+ demo
+ 0.0.1-SNAPSHOT
+
+
+ org.mockito
+ mockito-core
+ 5.13.0
+ test
+
+
+ net.bytebuddy
+ byte-buddy
+ 1.12.19
+ test
+
+
+
+ """,
+ spec -> spec.after(after -> """
+
+ 4.0.0
+ com.example
+ demo
+ 0.0.1-SNAPSHOT
+
+
+ org.mockito
+ mockito-core
+ %s
+ test
+
+
+ net.bytebuddy
+ byte-buddy
+ %s
+ test
+
+
+
+ """.formatted(
+ Pattern.compile("(5.+)").matcher(after).results().findFirst().orElseThrow().group(1),
+ Pattern.compile("(1.15.+)").matcher(after).results().findFirst().orElseThrow().group(1)))
)
);
}