Preserve CharSequence assertions in sequenced collections - #1095
Open
martinfrancois wants to merge 2 commits into
Open
Preserve CharSequence assertions in sequenced collections#1095martinfrancois wants to merge 2 commits into
martinfrancois wants to merge 2 commits into
Conversation
Draft
4 tasks
martinfrancois
force-pushed
the
agent/repro-simplify-sequenced-string-assertion
branch
from
August 15, 2026 23:04
4f9ed39 to
fcd7c01
Compare
martinfrancois
force-pushed
the
agent/repro-simplify-sequenced-string-assertion
branch
from
August 16, 2026 02:53
fcd7c01 to
1dd7ed3
Compare
martinfrancois
marked this pull request as ready for review
August 17, 2026 08:05
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.
Suggested review order: 20 of 52 (Score: 6.5)
Review first: #1094
What's changed?
Leaves a sequenced-collection assertion unchanged when the selected element uses a CharSequence-specific AssertJ assertion. Assertions supported by the generic element assertion continue to use
.first()or.last().What's your motivation?
Recipe:
org.openrewrite.java.testing.assertj.SimplifySequencedCollectionAssertions.I found this by running
org.openrewrite.java.testing.assertj.SimplifySequencedCollectionAssertionsfromorg.openrewrite.recipe:rewrite-testing-frameworks:3.42.0onTrelloClientTest.javain Symphony-Trello ata8013f27. I reproduced the same result with the latest released recipe artifact,org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0../mvnw -DskipTests test-compilethen fails because.first()returnsObjectAssert<String>, which has nostartsWith(String)method.Before
Actual after the recipe
Expected after the recipe
(unchanged)The rewrite changes the AssertJ assertion type from a string assertion to a generic object assertion. The fluent string methods are then unavailable, so the transformed target does not compile.
Confirmed real-world execution
TrelloClientTest.javaata8013f27.martinfrancois/symphony-trello@a8013f27.Anything in particular you'd like reviewers to focus on?
Please review the assertion-chain scan and the distinction between generic equality assertions and CharSequence-specific operations.
Have you considered any alternatives or workarounds?
Adding another AssertJ narrowing operation would make the result more complex than the original. Leaving this chain unchanged is both shorter and type-safe.
Any additional context
Pre-existing tests changed:
SimplifySequencedCollectionAssertionsTest.java.withDifferentAssertions(updated).martinfrancois/symphony-trello@a8013f27org.openrewrite.recipe:rewrite-testing-frameworks:3.42.0org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0openrewrite/rewrite-testing-frameworks@23a04efcSimplifySequencedCollectionAssertionsTestThis change was prepared with AI assistance. I reviewed the target execution evidence, implementation, tests, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv