Skip to content

Commit

Permalink
Match any argument, as kotlin.Int fails to match (int)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 11, 2025
1 parent 4014f2d commit 9c00362
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;

import java.util.List;

import static java.util.Collections.emptyList;

public class SimplifyWebTestClientCalls extends Recipe {

private static final MethodMatcher IS_EQUAL_TO_INT_MATCHER = new MethodMatcher("org.springframework.test.web.reactive.server.StatusAssertions isEqualTo(int)");
private static final MethodMatcher IS_EQUAL_TO_MATCHER = new MethodMatcher("org.springframework.test.web.reactive.server.StatusAssertions isEqualTo(..)");

@Override
public String getDisplayName() {
Expand All @@ -47,11 +45,11 @@ public String getDescription() {

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return Preconditions.check(new UsesMethod<>(IS_EQUAL_TO_INT_MATCHER), new JavaIsoVisitor<ExecutionContext>() {
return Preconditions.check(new UsesMethod<>(IS_EQUAL_TO_MATCHER), new JavaIsoVisitor<ExecutionContext>() {
@Override
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
if (IS_EQUAL_TO_INT_MATCHER.matches(m.getMethodType())) {
if (IS_EQUAL_TO_MATCHER.matches(m.getMethodType())) {
final int statusCode = extractStatusCode(m.getArguments().get(0));
switch (statusCode) {
case 200:
Expand Down

0 comments on commit 9c00362

Please sign in to comment.