rewrite-testing-frameworks icon indicating copy to clipboard operation
rewrite-testing-frameworks copied to clipboard

org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ Omission

Open ChenyuWang98 opened this issue 2 months ago • 1 comments

After I executed org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ, many hamcrest sentences still remained.

import org.hamcrest.Matchers.*;
import org.hamcrest.Matchers;
import org.hamcrest.Matcher;
not(hasKey("a"))
is("a")
not(hasEntry("jpg","image/jpg))
not(isEmptyOrNullString())
instanceOf(A.class)
not(contains("aa"))
MockitoHamcrest.argThat(hasKey("asd"))
hasSize(greaterThanOrEqualTo(1))
Description
BaseMatcher

ChenyuWang98 avatar Dec 05 '25 06:12 ChenyuWang98

Thanks for sharing your findings @ChenyuWang98 ! Good to see what gaps there are left to cover; some of these look fairly straightforward to fill in.

As a bit of background a lot of these migrations are defined here: https://github.com/openrewrite/rewrite-testing-frameworks/blob/959c88b1fca5a59d1708d235555abd7418bdb6a0/src/main/resources/META-INF/rewrite/hamcrest.yml#L79-L367

For the not(contains("aa")) case above it seems like that was just missed, but should be easy to add based on this example: https://github.com/openrewrite/rewrite-testing-frameworks/blob/959c88b1fca5a59d1708d235555abd7418bdb6a0/src/main/resources/META-INF/rewrite/hamcrest.yml#L333-L338

Would you be open to helping fill these gaps?

timtebeek avatar Dec 05 '25 09:12 timtebeek