Skip to content

Commit

Permalink
Add MockRestServiceServer.verify to default assertions (#593)
Browse files Browse the repository at this point in the history
* add MockRestServiceServer.verify to default assertions

* Move spring-test to src/test/resources, as it's only needed there

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
  • Loading branch information
ArloL and timtebeek authored Sep 6, 2024
1 parent fd664b2 commit 8d8970d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
"""
)
);
}
}
Binary file not shown.

0 comments on commit 8d8970d

Please sign in to comment.