Migrate EasyMock code to Mockito

MSAL

Change EasyMock types, mock creation, expectations and argument matchers to their Mockito equivalents, and remove replay and verify calls.

org.openrewrite.java.testing.easymock.EasyMockCodeToMockito
mod run . --recipe=org.openrewrite.java.testing.easymock.EasyMockCodeToMockito

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. Replace EasyMock verify calls with Mockito verify calls
  2. Remove method invocations org.easymock.IExpectationSetters times(..)
  3. Remove method invocations org.easymock.IExpectationSetters once()
  4. Remove method invocations org.easymock.IExpectationSetters atLeastOnce()
  5. Remove method invocations org.easymock.IExpectationSetters anyTimes()
  6. Remove method invocations org.easymock.IMocksControl replay(..)
  7. Remove method invocations org.easymock.EasyMock replay(..)
  8. Remove method invocations org.easymock.IMocksControl verify(..)
  9. Remove method invocations org.easymock.IMocksControl verifyRecording(..)
  10. Remove method invocations org.easymock.IMocksControl verifyUnexpectedCalls(..)
  11. Remove method invocations org.easymock.EasyMockSupport replayAll()
  12. Remove method invocations org.easymock.EasyMockSupport verifyAll()
  13. Change method name org.easymock.IExpectationSetters andReturn(..) to thenReturn
  14. Change method name org.easymock.IExpectationSetters andThrow(java.lang.Throwable) to thenThrow
  15. Change method name org.easymock.IExpectationSetters andAnswer(..) to thenAnswer
  16. Change method name org.easymock.IExpectationSetters andStubReturn(..) to thenReturn
  17. Change method name org.easymock.IExpectationSetters andStubThrow(java.lang.Throwable) to thenThrow
  18. Change method name org.easymock.IExpectationSetters andStubAnswer(..) to thenAnswer
  19. Change method target to static
  20. Change method target to static
  21. Change type IArgumentMatcher to ArgumentMatcher
  22. Change method name org.easymock.EasyMock anyObject(..) to any
  23. Change method name org.easymock.EasyMock capture(..) to argThat
  24. Change method name org.easymock.EasyMock reportMatcher(..) to argThat
  25. Change method name org.easymock.EasyMock expect(..) to when
  26. Change method name org.easymock.EasyMock createNiceMock(..) to mock
  27. Change method name org.easymock.EasyMock createStrictMock(..) to mock
  28. Change method name org.easymock.EasyMock createMock(..) to mock
  29. Change method name org.easymock.EasyMock niceMock(..) to mock
  30. Change method name org.easymock.EasyMock strictMock(..) to mock
  31. Reorder method arguments
  32. Change method target to static
  33. Change method target to static
  34. Change method target to static
  35. Change method target to static
  36. Change method target to static
  37. Change method target to static
  38. Change method target to static
  39. Remove extends EasyMockSupport from test classes
  40. Change type EasyMock to Mockito
  41. Change type EasyMockRunner to MockitoJUnitRunner
  42. Change type org.easymock.Mock to org.mockito.Mock
  43. Change type TestSubject to InjectMocks