-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate JMockit Verifications to Mockito (#540)
* First draft of adding feature to migration JMockit Verifications to Mockito verify statements. Tests are failing, need to fix and also add tests once they pass. * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Add more test cases, fix existing test cases, refactor method name. Some test still failing. * Refactor everything to be simpler to understand, also remove empty new line between migrated mockit when statements as mockito statements are more compact than Expectations * Add support for multiple statements in Verifications to be migrated by replacing the Verification block * Add test case with blank lines in Verification block to be erased * Remove trailing whitespaces in text blocks * Refactor * Refactor method and variable names. One test case failing when we use an external class to mock an object * Try to debug issue where seeing very strange behaviour in code, where when we change the expected output to the actual generated output by including the static import, we get error that the type is missing or malformed. This looks like a bug in the framework. It seems to only occur when we add a second class in the before. * Skip type validation after template `verify(#{any()}).#{}(#{any()})` * Add missing nullable annotations; add Lombok annotations * Apply suggestions from code review --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <[email protected]>
- Loading branch information
1 parent
fd0eb2d
commit 2096894
Showing
9 changed files
with
1,175 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
289 changes: 135 additions & 154 deletions
289
...ng/jmockit/ExpectationsBlockRewriter.java → ...testing/jmockit/JMockitBlockRewriter.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/openrewrite/java/testing/jmockit/JMockitBlockType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openrewrite.java.testing.jmockit; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
enum JMockitBlockType { | ||
|
||
Expectations("mockit.Expectations"), | ||
Verifications("mockit.Verifications"); // Add NonStrictExpectations later | ||
|
||
private final String fqn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.