Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hamcrest Is matcher from core #498

Merged
merged 5 commits into from
Apr 14, 2024

Conversation

timo-abele
Copy link
Contributor

@timo-abele timo-abele commented Mar 13, 2024

this testcase uses a different import for the is matcher

What's changed?

added a testcase where the is matcher is imported via import static org.hamcrest.core.Is.is;

What's your motivation?

Fix #497

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

this testcase uses a different import for the is matcher
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • src/test/java/org/openrewrite/java/testing/datafaker/JavaFakerToDataFakerTest.java
    • lines 19-18
    • lines 33-32

@timtebeek
Copy link
Contributor

Thanks for the helpful test to reproduce & pointing out the likely cause. We can either change the Java recipe, or run a declarative recipe before this change to get this to work, as indicated here.

An addition of this recipe

  - org.openrewrite.java.ChangeMethodTargetToStatic:
      methodPattern: org.hamcrest.core.Is is(..)
      fullyQualifiedTargetTypeName: org.hamcrest.Matchers

As the very first recipe here would allow both RemoveIsMatcher and HamcrestIsMatcherToAssertJ to work cases that currently use org.hamcrest.core.Is.

recipeList:
# First remove wrapping `is(Matcher)` calls such that further recipes will match
- org.openrewrite.java.testing.hamcrest.RemoveIsMatcher
# Then remove calls to `MatcherAssert.assertThat(String, is(Matcher))`
- org.openrewrite.java.testing.hamcrest.HamcrestIsMatcherToAssertJ

Might be worth exploring if there's similar cases that could benefit from such a standardization-ahead-of-migration as well, but optional for this PR.

Thanks for helping figure this one out!

@timtebeek timtebeek added bug Something isn't working good first issue Good for newcomers labels Mar 14, 2024
@timtebeek timtebeek self-requested a review April 14, 2024 21:10
@timtebeek timtebeek marked this pull request as ready for review April 14, 2024 21:10
@timtebeek
Copy link
Contributor

Thanks for getting this started @timo-abele! I've moved the test and applied the above suggestion such that it now passes. Good to have this covered!

@timtebeek timtebeek merged commit 78e884a into openrewrite:main Apr 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

AssertJ skips is
2 participants