Skip to content

Transform Assume methods to without a direct counterpart to equivalent Assumptions#889

Merged
timtebeek merged 10 commits intoopenrewrite:mainfrom
cortlepp:fix-junit-assume-to-assumptions
Jan 13, 2026
Merged

Transform Assume methods to without a direct counterpart to equivalent Assumptions#889
timtebeek merged 10 commits intoopenrewrite:mainfrom
cortlepp:fix-junit-assume-to-assumptions

Conversation

@cortlepp
Copy link
Contributor

What's changed?

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@cortlepp
Copy link
Contributor Author

@timtebeek this is my current wip. but I have some questions before I can move forward:

  1. I need junit on the classpath to write the template, but I'm not sure if that is intended
  2. The normal test currently fails with org.openrewrite.internal.RecipeRunException: java.lang.IllegalArgumentException: Unable to find classpath resource dependencies beginning with: 'opentest4j-1', maybe my added junit dependency messed something up there?
  3. I'm not sure if I got the Object... case right. It's not important to me in particular, but I thought since we're already at it...
  4. I'm not sure if the way this recipe is called from org.openrewrite.java.testing.junit5.MigrateAssumptions now actually works, since technically that recipe makes illegal changes (in the sense that they wouldn't compile). A solution would be to reimplement all of this in refaster, but I don't know if that is necessary

@timtebeek timtebeek marked this pull request as ready for review January 13, 2026 13:46
@timtebeek timtebeek changed the title Fix junit assume to assumptions (#886) Transform Assume methods to without a direct counterpart to equivalents in Assumptions Jan 13, 2026
Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the help here @cortlepp ! There were a few trickier cases with your setup indeed:

  1. we needed to add a parserClasspath entry and run ./gradlew cTT as seen here
  2. we needed a @Matches to avoid over eager replacement of Object...
  3. the case for two arguments doens't currently match correct; that'll be an upstream fix
  4. I've replaced Arrays.stream with Stream.of, as that would in theory accept more than one argument in the future.
  5. I've renamed your recipe to reflect the smaller scope: we're for now only changing NotNull assumptions. (unless you want to change that here already)

Hope you agree with the changes and can learn from the work I've shared. Thanks again!

We can already merge at this stage, unless you have more you want to add right now already.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jan 13, 2026
@timtebeek timtebeek added recipe Recipe request junit labels Jan 13, 2026
@timtebeek timtebeek changed the title Transform Assume methods to without a direct counterpart to equivalents in Assumptions Transform Assume methods to without a direct counterpart to equivalent Assumptions Jan 13, 2026
@cortlepp
Copy link
Contributor Author

@timtebeek Wow that added up to quite a bit more fixes than I was expecting, thanks! I'm okay with merging this as-is.

@timtebeek
Copy link
Member

Thanks! Yes figured show you the way rather than ask you to make all those changes 🙏🏻. Good to see Assumptions covered!

@timtebeek timtebeek merged commit e9dab31 into openrewrite:main Jan 13, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jan 13, 2026
mergify bot added a commit to robfrank/linklift that referenced this pull request Jan 25, 2026
…rom 3.25.0 to 3.26.0 [skip ci]

[//]: # (dependabot-start)
⚠️ \*\*Dependabot is rebasing this PR\*\* ⚠️
Rebasing might not happen immediately, so don't worry if this takes some time.
Note: if you make any changes to this PR yourself, they will take precedence over the rebase.
---
[//]: # (dependabot-end)
Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.25.0 to 3.26.0.
Release notes

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

> 3.26.0
> ------
>
> What's Changed
> --------------
>
> * Transform `Assume` methods to without a direct counterpart to equivalent `Assumptions` by [`@​cortlepp`](https://github.com/cortlepp) in [openrewrite/rewrite-testing-frameworks#889](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/889)
> * Apply Kotlin style class reference in `AddMockitoExtensionIfAnnotationsUsed` by [`@​Laurens-W`](https://github.com/Laurens-W) in [openrewrite/rewrite-testing-frameworks#890](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/890)
>
> New Contributors
> ----------------
>
> * [`@​cortlepp`](https://github.com/cortlepp) made their first contribution in [openrewrite/rewrite-testing-frameworks#889](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/889)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.25.0...v3.26.0>


Commits

* [`17ef798`](openrewrite/rewrite-testing-frameworks@17ef798) Replace `getEstimatedEffortPerOccurrence()` method with field
* [`49b6e85`](openrewrite/rewrite-testing-frameworks@49b6e85) Replace `getTags()` method with field
* [`cec049e`](openrewrite/rewrite-testing-frameworks@cec049e) Update Gradle wrapper to 9.3.0
* [`ae15942`](openrewrite/rewrite-testing-frameworks@ae15942) Use `hasModifier` instead of `getModifiers().stream().anyMatch()`
* [`3c16fbc`](openrewrite/rewrite-testing-frameworks@3c16fbc) Replace `getDisplayName()` and `getDescription()` methods with fields
* [`7150900`](openrewrite/rewrite-testing-frameworks@7150900) OpenRewrite recipe best practices
* [`2c43283`](openrewrite/rewrite-testing-frameworks@2c43283) Apply Kotlin style class reference in `AddMockitoExtensionIfAnnotationsUsed` ...
* [`e9dab31`](openrewrite/rewrite-testing-frameworks@e9dab31) Transform `Assume` methods to without a direct counterpart to equivalent `Ass...
* [`aefa2b0`](openrewrite/rewrite-testing-frameworks@aefa2b0) Replace `getDisplayName()` and `getDescription()` methods with fields
* [`945be5c`](openrewrite/rewrite-testing-frameworks@945be5c) `AssertTrueInstanceofToAssertInstanceOf` should handle custom types
* See full diff in [compare view](openrewrite/rewrite-testing-frameworks@v3.25.0...v3.26.0)
  
[![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.25.0&new-version=3.26.0)](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

junit recipe Recipe request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants