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

JMockit to Mockito IllegalArumentException No enum constant VerificationsInOrder #616

Conversation

shivanisky
Copy link
Collaborator

@shivanisky shivanisky commented Oct 11, 2024

What's changed?

IllegalArgumentException generated when running jmockit to mockito recipe on code containing jmockit block VerificationsInOrder, raised here jmockit/jmockit1#729 (comment)

https://javadoc.io/doc/org.jmockit/jmockit/latest/mockit/VerificationsInOrder.html

Stack trace

lang.IllegalArgumentException: No enum constant org.openrewrite.java.testing.jmo
ckit.JMockitBlockType.VerificationsInOrder
[ERROR] java.base/java.lang.Enum.valueOf(Enum.java:273)
[ERROR] org.openrewrite.java.testing.jmockit.JMockitBlockType.valueOf(JMockitB
lockType.java:20)
[ERROR] org.openrewrite.java.testing.jmockit.JMockitUtils.getJMockitBlock(JMoc
kitUtils.java:46)
[ERROR] org.openrewrite.java.testing.jmockit.SetupStatementsRewriter.rewriteMe
thodBody(SetupStatementsRewriter.java:41)
[ERROR] org.openrewrite.java.testing.jmockit.JMockitBlockToMockito$RewriteJMoc
kitBlockVisitor.visitMethodDeclaration(JMockitBlockToMockito.java:66)
[ERROR] org.openrewrite.java.testing.jmockit.JMockitBlockToMockito$RewriteJMoc
kitBlockVisitor.visitMethodDeclaration(JMockitBlockToMockito.java:56)

Anyone you would like to review specifically?

@timtebeek @tinder-dthomson (understand he may be busy)

Have you considered any alternatives or workarounds?

Yes - actually do migrate the above JMockit block. Need to use Mockito inOrder.verify(...). This will take time to do, so for now, just skipping migrating this block without generating exception. Anyway, we should ensure that any unsupported JMockit block types are not migrated, so this fix should be done anyway.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@shivanisky shivanisky self-assigned this Oct 11, 2024
@timtebeek timtebeek changed the title Bugfix/JMockit to Mockito IllegalArumentException No enum constant VerificationsInOrder JMockit to Mockito IllegalArumentException No enum constant VerificationsInOrder Oct 11, 2024
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see! Thanks for monitoring that thread and coming through with the fix here. ❤️

@shivanisky shivanisky merged commit 6fff817 into main Oct 11, 2024
2 checks passed
@shivanisky shivanisky deleted the bugfix/IllegalArgumentException-No-enum-constant-VerificationsInOrder branch October 11, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants