Conversation
…type matching in CollapseConsecutiveAssertThatStatements - Add .contextSensitive() to JavaTemplate builders in HamcrestMatcherToAssertJ, HamcrestNotMatcherToAssertJ, and HamcrestIsMatcherToAssertJ to ensure templates are compiled in proper source context - Improve CollapseConsecutiveAssertThatStatements with fallback for partially resolved SELF return types (e.g., when assertion methods return AbstractIterableAssert instead of ListAssert) - Update test expectations: isNotNull() now collapses with other assertions and is removed by SimplifyRedundantAssertJChains - Add test case for custom types to verify hamcrest-to-AssertJ conversion works Fixes the issue where the AssertJ best practices recipe required multiple runs on Hamcrest test files before seeing chained assertions.
timtebeek
commented
Feb 21, 2026
Comment on lines
188
to
190
| assertThat(biscuits).hasSize(3); | ||
| assertThat(biscuits).contains(new Biscuit("Chocolate")); | ||
| assertThat(biscuits).doesNotContain(new Biscuit("Raisin")); |
Member
Author
There was a problem hiding this comment.
Ideally these are collapsed as well.
Use #{any(java.util.List)} instead of #{any()} for Java standard library
types in HamcrestMatcherToAssertJ.typeToIndicator(). This gives the
template parser enough type information to resolve the correct assertThat
overload, producing proper return types even when generic type parameters
reference custom types not on the template parser classpath.
This enables CollapseConsecutiveAssertThatStatements to chain assertions
on custom types (like List<Biscuit>) in a single pass, no longer
requiring TypeValidation.none() in tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the issue where the AssertJ best practices recipe required multiple runs on Hamcrest test files before seeing chained assertions.