openrewrite / rewrite-testing-frameworks

OpenRewrite recipes that perform common Java testing migration tasks.
Apache License 2.0
74 stars 67 forks source link

PowerMockito `doThrow(Throwable).when(Class, String, any())` not converted to Mockito single argument `when` #597

Open anand188 opened 1 week ago

anand188 commented 1 week ago

I am using

org.openrewrite.maven rewrite-maven-plugin 5.39.2 true org.openrewrite.java.testing.mockito.ReplacePowerMockito org.openrewrite.recipe rewrite-testing-frameworks 2.17.0

Is your project a single module or a multi-module project? Yes

Can you share your configuration so that we can rule out any configuration issues?

Is your project public? If so, can you share a link to it? no

timtebeek commented 1 week ago

Hi @anand188 ; There's been a recent fix to the Powermock migration recipe in:

Would you mind trying again with the latest version? https://github.com/openrewrite/rewrite-testing-frameworks/releases/tag/v2.17.1

Beyond that your question lacks the details we need to replicate the issue; if the problems persist with the latest version I suggest you create a minimal reproducer.

anand188 commented 1 week ago

@timtebeek tried 2.17.1 also doesn't seem to address the issue same not completing migrating.

anand188 commented 1 week ago

PowerMockito.doThrow(new IllegalArgumentException()).when( xx.class,"abc",any()) these are still not migrated because when in Mockito only takes single argument unlike PowerMockito

timtebeek commented 1 week ago

Ah yes that form is not yet support; that makes this sounds more like a feature request to expand coverage of our Powermock migration recipe. Would you be willing to help out with it's implementation?

The first step would be a draft pull request that adds your case to this unit test; we can collaborate from there: https://github.com/openrewrite/rewrite-testing-frameworks/blob/e9497f1a56e075d5359a10b6356d580dc0ac5874/src/test/java/org/openrewrite/java/testing/mockito/ReplacePowerMockitoIntegrationTest.java#L620-L661

anand188 commented 4 days ago

@timtebeek thanks let me see if its possible for me to learn and update this