Replace PowerMock usages with Mockito

MSAL

Replaces the PowerMock API, runners, rules and annotations used in Java sources with their Mockito counterparts, and PowerMock Whitebox with Java reflection. Build files are left unchanged.

org.openrewrite.java.testing.mockito.ReplacePowerMockitoUsages
mod run . --recipe=org.openrewrite.java.testing.mockito.ReplacePowerMockitoUsages

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Remove annotation @org.powermock.core.classloader.annotations.PowerMockIgnore
  2. Remove annotation @org.powermock.core.classloader.annotations.SuppressStaticInitializationFor
  3. Replace PowerMock runner with JUnit @RunWith
  4. Replace PowerMock.mockStatic() with Mockito.mockStatic()
  5. Change method target to static
  6. Replace PowerMockito doX().when(instance, "method") with Mockito-compatible stubbing
  7. Replace PowerMockito.doX() with Mockito.doX()
  8. Change method target to static
  9. Change method target to static
  10. Change method target to static
  11. Change method target to static
  12. Change method target to static
  13. Remove PowerMockRule fields
  14. Remove PowerMock class extensions
  15. Remove annotation @org.powermock.core.classloader.annotations.PrepareForTest
  16. Remove annotation @org.powermock.core.classloader.annotations.PrepareOnlyThisForTest
  17. Remove annotation @org.powermock.core.classloader.annotations.PrepareEverythingForTest
  18. Replace PowerMockito.whenNew with Mockito counterpart
  19. Replace PowerMock Whitebox.setInternalState() with @InjectMocks
  20. Replace PowerMock Whitebox with Java reflection
  21. Cleanup PowerMock imports