-
Notifications
You must be signed in to change notification settings - Fork 72
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
Migrate Jmockit VerificationsInOrder to Mockito #632
base: main
Are you sure you want to change the base?
Conversation
…ith Mockito InOrder statement. Also need to support multiple VerificationsInOrder blocks in one method.
… for multiple blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see you follow through with the penultimate feature needed to complete the JMockit migrations. I've done a very quick round of comments from GitHub; will need to look in more detail later.
|
||
class JMockitBlockRewriter { | ||
|
||
private static final String WHEN_TEMPLATE_PREFIX = "when(#{any()})."; | ||
private static final String VERIFY_TEMPLATE_PREFIX = "verify(#{any()}"; | ||
private static final String VERIFY_NO_INTERACTIONS_TEMPLATE_PREFIX = "verifyNoMoreInteractions("; | ||
private static final String VERIFY_IN_ORDER_TEMPLATE_PREFIX = "inOrder("; | ||
//private static final String VERIFY_IN_ORDER_TEMPLATE_PREFIX = "InOrder inOrder = inOrder("; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//private static final String VERIFY_IN_ORDER_TEMPLATE_PREFIX = "InOrder inOrder = inOrder("; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes - this is one issue I'd like to get input on
inOrder(mock) works, but
InOrder inOrder = inOrder(mock) causes error even though I have the right compilation options and the right import. Hence I am not able to get all the tests passing (have disabled for now).
Caused by: java.lang.IllegalArgumentException: Could not parse as Java
at org.openrewrite.java.internal.template.JavaTemplateParser.lambda$compileTemplate$13(JavaTemplateParser.java:264)
at java.base/java.util.Optional.orElseThrow(Optional.java:403)
at org.openrewrite.java.internal.template.JavaTemplateParser.compileTemplate(JavaTemplateParser.java:264)
at org.openrewrite.java.internal.template.JavaTemplateParser.lambda$parseBlockStatements$9(JavaTemplateParser.java:176)
at org.openrewrite.java.internal.template.JavaTemplateParser.lambda$cacheIfContextFree$14(JavaTemplateParser.java:287)
at org.openrewrite.java.internal.template.JavaTemplateParser.cache(JavaTemplateParser.java:308)
at org.openrewrite.java.internal.template.JavaTemplateParser.cacheIfContextFree(JavaTemplateParser.java:287)
at org.openrewrite.java.internal.template.JavaTemplateParser.parseBlockStatements(JavaTemplateParser.java:171)
at org.openrewrite.java.internal.template.JavaTemplateJavaExtension$1.lambda$visitBlock$1(JavaTemplateJavaExtension.java:112)
at org.openrewrite.internal.ListUtils.lambda$flatMap$0(ListUtils.java:261)
at org.openrewrite.internal.ListUtils.flatMap(ListUtils.java:205)
at org.openrewrite.internal.ListUtils.flatMap(ListUtils.java:261)
at org.openrewrite.java.internal.template.JavaTemplateJavaExtension$1.visitBlock(JavaTemplateJavaExtension.java:110)
at org.openrewrite.java.internal.template.JavaTemplateJavaExtension$1.visitBlock(JavaTemplateJavaExtension.java:55)
at org.openrewrite.java.tree.J$Block.acceptJava(J.java:838)
at org.openrewrite.java.tree.J.accept(J.java:59)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
... 58 more
src/main/java/org/openrewrite/java/testing/jmockit/JMockitBlockRewriter.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/testing/jmockit/JMockitBlockRewriter.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/testing/jmockit/JMockitBlockRewriter.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Tim te Beek <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
Co-authored-by: Tim te Beek <[email protected]>
What's changed?
Add feature to migrate Jmockit VerificationsInOrder to mockito https://javadoc.io/doc/org.jmockit/jmockit/latest/mockit/VerificationsInOrder.html
https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/InOrder.html
What's your motivation?
Anyone you would like to review specifically?
@sambsnyd @timtebeek @tinder-dthomson as FYI
Any additional context
Only JMockit Expectations Delegate left to migrate.
Checklist