Skip to content

Add recipe to simplify AssertJ SequencedCollection assertions#837

Merged
timtebeek merged 2 commits intomainfrom
assertthat-last
Nov 2, 2025
Merged

Add recipe to simplify AssertJ SequencedCollection assertions#837
timtebeek merged 2 commits intomainfrom
assertthat-last

Conversation

@timtebeek
Copy link
Member

Summary

  • Adds new SimplifySequencedCollectionAssertions recipe to transform AssertJ assertions on SequencedCollection methods
  • Transforms assertThat(collection.getLast())assertThat(collection).last()
  • Transforms assertThat(collection.getFirst())assertThat(collection).first()
  • Includes comprehensive test coverage for various scenarios

Test plan

  • Created test class with multiple test cases covering different scenarios
  • Tests verify transformation of both getFirst() and getLast() methods
  • Tests verify behavior with follow-up assertions
  • Tests verify no changes to non-SequencedCollection code
  • Run full test suite once build environment is available

🤖 Generated with Claude Code

Transforms assertThat(collection.getLast()) to assertThat(collection).last()
and assertThat(collection.getFirst()) to assertThat(collection).first() for
cleaner and more idiomatic AssertJ assertions on SequencedCollections.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Nov 2, 2025
@timtebeek timtebeek self-assigned this Nov 2, 2025
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Nov 2, 2025
@timtebeek
Copy link
Member Author

@rickie any plans to bump error-prone-support up to using Java 21? Because this could have been a relatively straightforward refaster recipe as well otherwise.

@timtebeek timtebeek added recipe Recipe request assertj labels Nov 2, 2025
@timtebeek timtebeek merged commit 345ac0a into main Nov 2, 2025
2 checks passed
@timtebeek timtebeek deleted the assertthat-last branch November 2, 2025 22:50
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Nov 2, 2025
@rickie
Copy link

rickie commented Nov 3, 2025

Yes, soon! PicnicSupermarket/error-prone-support#1927

@Stephan202
Copy link

Some rules using SequencedCollection are introduced in PicnicSupermarket/error-prone-support#194, but the ones mentioned here would be welcome too!

mergify bot added a commit to robfrank/linklift that referenced this pull request Nov 10, 2025
…rom 3.20.0 to 3.21.2 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.20.0 to 3.21.2.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).*

> v3.21.2
> -------
>
> What's Changed
> --------------
>
> * Depend on rewrite-third-party for the type table entries by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#841](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/841)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.21.1...v3.21.2>
>
> v3.21.1
> -------
>
> What's Changed
> --------------
>
> * Add JUnit 6 type table entries by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#839](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/839)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.21.0...v3.21.1>
>
> 3.21.0
> ------
>
> What's Changed
> --------------
>
> * OpenRewrite recipe best practices by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#834](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/834)
> * Gradle 9.2.0 by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#836](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/836)
> * Add recipe to simplify AssertJ SequencedCollection assertions by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#837](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/837)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.20.0...v3.21.0>


Commits

* [`4a3bf4e`](openrewrite/rewrite-testing-frameworks@4a3bf4e) Depend on rewrite-third-party for the type table entries ([#841](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/841))
* [`111daea`](openrewrite/rewrite-testing-frameworks@111daea) Add JUnit 6 type table entries ([#839](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/839))
* [`91418e6`](openrewrite/rewrite-testing-frameworks@91418e6) OpenRewrite recipe best practices
* [`345ac0a`](openrewrite/rewrite-testing-frameworks@345ac0a) Add recipe to simplify AssertJ SequencedCollection assertions ([#837](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/837))
* [`37e86b7`](openrewrite/rewrite-testing-frameworks@37e86b7) Gradle 9.2.0 ([#836](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/836))
* [`766f6be`](openrewrite/rewrite-testing-frameworks@766f6be) OpenRewrite recipe best practices ([#834](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/834))
* [`e85e34d`](openrewrite/rewrite-testing-frameworks@e85e34d) Clean up leftover calls to TestCase.super()
* [`2bed89d`](openrewrite/rewrite-testing-frameworks@2bed89d) Fix XmlUnit test to no longer break on new minor or patch releases
* See full diff in [compare view](openrewrite/rewrite-testing-frameworks@v3.20.0...v3.21.2)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-testing-frameworks&package-manager=maven&previous-version=3.20.0&new-version=3.21.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assertj recipe Recipe request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants