Skip to content

Commit b1e8bf0

Browse files
Context free SimplifyAssertJAssertion (#570)
* Context free SimplifyAssertJAssertion * Apply suggestions from code review Co-authored-by: Knut Wannheden <[email protected]> --------- Co-authored-by: Knut Wannheden <[email protected]>
1 parent 8a037e8 commit b1e8bf0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/org/openrewrite/java/testing/assertj/SimplifyAssertJAssertion.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation methodInvocat
9595
}
9696

9797
// Assume zero argument replacement method
98-
return JavaTemplate.builder(dedicatedAssertion + "()")
99-
.contextSensitive()
98+
return JavaTemplate.builder("#{any()}." + dedicatedAssertion + "()")
10099
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "assertj-core-3.24"))
101100
.build()
102-
.apply(getCursor(), mi.getCoordinates().replaceMethod());
101+
.apply(getCursor(), mi.getCoordinates().replace(), mi.getSelect());
103102
}
104103
}
105104
}

0 commit comments

Comments
 (0)