-
Notifications
You must be signed in to change notification settings - Fork 497
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description/ Observed Behavior
When attempting to use the ChangeType recipe to swap org.mockito.Matchers (used in mockito 1) with org.mockito.ArgumentMatchers (used in mockito 2+) I observed that the import statements in the resulting code are missing the "org.mockito" bit.
Here's an example of the visitor:
@AutoConfigure
public class ReplaceMatchersWithArgumentMatchers extends JavaRefactorVisitor {
private final ChangeType changeAny = new ChangeType();
public ReplaceMatchersWithArgumentMatchers() {
changeAny.setType("org.mockito.Matchers");
changeAny.setTargetType("org.mockito.ArgumentMatchers");
}
@Override
public J visitCompilationUnit(J.CompilationUnit cu) {
return changeAny.visitCompilationUnit(cu);
}
}Operating on code with imports like these:
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;Produces these invalid import statements:
import static ArgumentMatchers.any;
import static ArgumentMatchers.anyBoolean;This isn't specific to the imports being static, all imports are affected.
Desired Behavior
This transformation should produce import statements like:
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;Repro Steps
- Clone the rewrite-spring project
- Switch to the "mockito" branch
- Run the tests in ReplaceMatchersWithArgumentMatchersTest.kt
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working