Replace PowerMockito.whenNew with Mockito counterpart
MSALReplaces PowerMockito.whenNew(Type.class).with...().thenReturn(instance) with Mockito.mockConstructionWithAnswer(Type.class, delegatesTo(instance)), assigned to a field that is closed after each test. Every Type constructed while the mock is active delegates to instance, so stubbing and verification on instance keep working. Constructor argument matchers are not retained, and when the same type is stubbed more than once in a method, the calls are left unchanged.
org. openrewrite. java. testing. mockito. PowerMockitoWhenNewToMockitomod run . --recipe= org. openrewrite. java. testing. mockito. PowerMockitoWhenNewToMockitoInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.