Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MockRestServiceServer.verify to default assertions #593

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.