-
Notifications
You must be signed in to change notification settings - Fork 79
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
Code does not compile after AssertionsForClassTypes import is replaced by Assertions #664
Comments
Thanks for the report! Curious case; that'l likely stem from these lines that have been in there since 2021: rewrite-testing-frameworks/src/main/resources/META-INF/rewrite/assertj.yml Lines 61 to 63 in fc9d8b4
The Is there any other way to make it work with |
I think the root cause is a combination of how the client code uses AssertJ classes and the expectation behind that, with how
To better describe what happens with the example in this ticket, assuming the usage of AssertJ 3.27.3: AssertionsForClassTypes.assertThat(Map.of("a", 1).entrySet()) // returns ObjectAssert
.hasNoNullFieldsOrProperties(); // passes, but what is the expected semantic for Set<Entry<K, V>> ?
AssertionsForInterfaceTypes.assertThat(Map.of("a", 1).entrySet()) // returns AbstractCollectionAssert
.hasNoNullFieldsOrProperties(); // does not compile
Assertions.assertThat(Map.of("a", 1).entrySet()) // returns AbstractCollectionAssert
.hasNoNullFieldsOrProperties(); // does not compile Given that Assertions.assertThatObject(Map.of("a", 1).entrySet()) // returns ObjectAssert
.hasNoNullFieldsOrProperties(); // passes, but what is the expected semantic? I'm not saying that such a replacement should be suggested by Open Rewrite; I still believe the initial code has a semantic flaw, therefore it isn't something I would expect OpenRewrite to address. Nevertheless, we'll discuss within the team whether there is anything we can improve in AssertJ. Ideally, there shouldn't be so many options when importing |
Thanks for the detailed explanation! It sounds like perhaps the original test case above is perhaps not the best use of assertions, brought to light by the recipe change here. To avoid confusion perhaps something like |
We already introduced variants like My gut feeling (not yet discussed with the team) would be to deprecate both |
What version of OpenRewrite are you using?
I am using 3.0.0
How are you running OpenRewrite?
not relevant
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
What did you see instead?
Code does not compile anymore after this change.
What is the full stack trace of any errors you encountered?
Are you interested in contributing a fix to OpenRewrite?
yes
The text was updated successfully, but these errors were encountered: