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

Issue discovered on core/src/testFixtures/java/org/assertj/core/api/IdListAssert.java with Simplify AssertJ chained assertions #509

Open
timtebeek opened this issue Apr 19, 2024 · 1 comment
Labels
assertj bug Something isn't working

Comments

@timtebeek
Copy link
Contributor

timtebeek commented Apr 19, 2024

Problem

Describe the issue you are experiencing.

Expected behavior

Describe what you expected to see.

Example diff

From: core/src/testFixtures/java/org/assertj/core/api/IdListAssert.java

@Override
public IdListAssert<T> hasSize(int expected) {
-        return (IdListAssert<T>) super.hasSize(expected);
+        return (IdListAssert<T>) {{80000000-0000-005f-0000-000000000000}}super.hasSize(expected){{80000000-0000-005f-0000-000000000000}};
}

@Override

Recipes in example diff:

  • org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion

Error messages:

java.lang.ClassCastException: class org.openrewrite.java.tree.J$Identifier cannot be cast to class org.openrewrite.java.tree.J$MethodInvocation (org.openrewrite.java.tree.J$Identifier and org.openrewrite.java.tree.J$MethodInvocation are in unnamed module of loader 'app')
org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion$SimplifyChainedAssertJAssertionsVisitor.visitMethodInvocation(SimplifyChainedAssertJAssertion.java:105)
org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion$SimplifyChainedAssertJAssertionsVisitor.visitMethodInvocation(SimplifyChainedAssertJAssertion.java:90)
org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3932)
org.openrewrite.java.tree.J.accept(J.java:59)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:283)
org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:366)
org.openrewrite.java.JavaVisitor.visitTypeCast(JavaVisitor.java:1229)
org.openrewrite.java.JavaIsoVisitor.visitTypeCast(JavaIsoVisitor.java:320)
org.openrewrite.java.JavaIsoVisitor.visitTypeCast(JavaIsoVisitor.java:30)
org.openrewrite.java.tree.J$TypeCast.acceptJava(J.java:5470)
org.openrewrite.java.tree.J.accept(J.java:59)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:283)
org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:366)
org.openrewrite.java.JavaVisitor.visitReturn(JavaVisitor.java:1102)
org.openrewrite.java.JavaIsoVisitor.visitReturn(JavaIsoVisitor.java:280)
org.openrewrite.java.JavaIsoVisitor.visitReturn(JavaIsoVisitor.java:30)
...

References:

  • View original result
  • Recipe ID: org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion
  • Recipe Name: Simplify AssertJ chained assertions
  • Repository: jobrunr/jobrunr/master
  • Created at Fri Apr 19 2024 14:37:33 GMT+0200 (Central European Summer Time)
@timtebeek timtebeek added the bug Something isn't working label Apr 19, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Apr 20, 2024
@timtebeek
Copy link
Contributor Author

Looks to be an odd case of an AssertJ class imported into the project itself:
https://github.com/jobrunr/jobrunr/blob/v7.0.0/core/src/testFixtures/java/org/assertj/core/api/IdListAssert.java
That would explain why we get super identifier instead of an assertThat methodInvocation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertj bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant