diff --git a/build.gradle.kts b/build.gradle.kts index f49cd8098..bce1547cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,7 @@ recipeDependencies { parserClasspath("org.powermock:powermock-api-mockito:1.7.+") parserClasspath("org.powermock:powermock-core:1.7.+") parserClasspath("com.squareup.okhttp3:mockwebserver:4.10.0") + parserClasspath("org.springframework:spring-test:6.1.12") } val rewriteVersion = rewriteRecipe.rewriteVersion.get() diff --git a/src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java b/src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java index 82e4290f0..24db0e09c 100644 --- a/src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java +++ b/src/main/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertions.java @@ -50,6 +50,7 @@ public class TestsShouldIncludeAssertions extends Recipe { "mockit", "io.restassured", "org.springframework.test.web.servlet.ResultActions", + "org.springframework.test.web.client.MockRestServiceServer.verify", "com.github.tomakehurst.wiremock.client.WireMock", "org.junit.Assert"// rarely, the test annotation is junit 5 but the assert is junit 4 ); diff --git a/src/test/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertionsTest.java b/src/test/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertionsTest.java index 1b7c5ce82..6b8baa713 100644 --- a/src/test/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertionsTest.java +++ b/src/test/java/org/openrewrite/java/testing/cleanup/TestsShouldIncludeAssertionsTest.java @@ -34,7 +34,7 @@ class TestsShouldIncludeAssertionsTest implements RewriteTest { public void defaults(RecipeSpec spec) { spec .parser(JavaParser.fromJavaVersion() - .classpathFromResources(new InMemoryExecutionContext(), "junit-4.13", "junit-jupiter-api-5.9", "mockito-all-1.10", "hamcrest-2.2", "assertj-core-3.24") + .classpathFromResources(new InMemoryExecutionContext(), "junit-4.13", "junit-jupiter-api-5.9", "mockito-all-1.10", "hamcrest-2.2", "assertj-core-3.24", "spring-test-6.1.12") .dependsOn( List.of( //language=java @@ -377,4 +377,26 @@ public void methodTest() { ) ); } + + @Test + void hasMockRestServiceServerVerify() { + //language=java + rewriteRun( + java( + """ + import org.junit.jupiter.api.Test; + import org.springframework.test.web.client.MockRestServiceServer; + + class AaTest { + private MockRestServiceServer mockServer; + + @Test + public void verifyTest() { + mockServer.verify(); + } + } + """ + ) + ); + } } diff --git a/src/test/resources/META-INF/rewrite/classpath/spring-test-6.1.12.jar b/src/test/resources/META-INF/rewrite/classpath/spring-test-6.1.12.jar new file mode 100644 index 000000000..df044b40f Binary files /dev/null and b/src/test/resources/META-INF/rewrite/classpath/spring-test-6.1.12.jar differ