Replace Mockito.when on static (non mock) with try-with-resource with MockedStatic

MSAL

Replace Mockito.when on static (non mock) with try-with-resource with MockedStatic as Mockito4 no longer allows this. For JUnit 4/5 & TestNG: When @Before* is used, a close call is added to the corresponding @After* method. This change moves away from implicit bytecode manipulation for static method stubbing, making mocking behavior more explicit and scoped to avoid unintended side effects.

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

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