Make subpackage recursion explicit in the JavaFaker and Fest renames - #1072
Merged
Conversation
Both of these `ChangePackage` rules omit `recursive` while depending on it,
so types in subpackages of `oldPackageName` were never migrated.
Verified against the published artifacts:
javafaker 1.0.2 -> datafaker 2.4.2
com.github.javafaker.idnumbers -> net.datafaker.idnumbers
com.github.javafaker.service -> net.datafaker.service
com.github.javafaker.service.files -> net.datafaker.service.files
fest-assert-core 2.0M10 -> assertj-core 3.26.3
org.fest.assertions.api.filter -> org.assertj.core.api.filter
Every subpackage maps exactly under prefix substitution, so recursion is
both safe and required here.
The existing tests could not catch this. `ChangePackage.recursive` is
`@Nullable` with no documented default, and a null was read as non-recursive
by the recipe's preconditions but as recursive by its visitor, so a subpackage
type was renamed only for files that also referenced a type sitting directly
in `oldPackageName` -- which the existing fixtures all do. The two new tests
import only a subpackage type and fail without this change.
3 tasks
mergify Bot
added a commit
to robfrank/linklift
that referenced
this pull request
Aug 20, 2026
…rom 3.43.0 to 3.44.0 [skip ci] Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.43.0 to 3.44.0. Release notes *Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).* > 3.44.0 > ------ > > What's Changed > -------------- > > * Use assertInstanceOf for expectCause(isA/instanceOf/is(X.class)) by [`@neil-mushell`](https://github.com/neil-mushell) in [openrewrite/rewrite-testing-frameworks#1069](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1069) > * Make subpackage recursion explicit in the JavaFaker and Fest renames by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1072](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1072) > * Handle `MockitoJUnitRunner.StrictStubs` in `MockitoJUnitRunnerToExtension` by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1079](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1079) > * Retain assertTrue/assertFalse(a.equals(null)) as is by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1075](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1075) > * Emit `threadMode = SEPARATE_THREAD` when migrating `@Test(timeout = N)` by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1076](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1076) > * Add a blank line after the `mocks` field generated in Kotlin sources by [`@MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1070](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1070) > * Do not convert constructors of types nested in a parameterized test class by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1081](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1081) > * Keep `static` on nested test classes with static members before Java 16 by [`@martinfrancois`](https://github.com/martinfrancois) in [openrewrite/rewrite-testing-frameworks#1082](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1082) > * Do not wrap class level `mockStatic` fields in try-with-resources by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1089](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1089) > * Fix `UpdateMockWebServerMockResponseTest` expectation by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1090](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1090) > > New Contributors > ---------------- > > * [`@martinfrancois`](https://github.com/martinfrancois) made their first contribution in [openrewrite/rewrite-testing-frameworks#1082](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1082) > > **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.43.0...v3.44.0> Commits * [`23a04ef`](openrewrite/rewrite-testing-frameworks@23a04ef) Align `MockResponse.Builder` type names in test expectation ([#1090](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1090)) * [`32ab90a`](openrewrite/rewrite-testing-frameworks@32ab90a) Do not wrap class level `mockStatic` fields in try-with-resources ([#1089](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1089)) * [`ded10c4`](openrewrite/rewrite-testing-frameworks@ded10c4) Keep `static` on nested test classes with static members before Java 16 ([#1082](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1082)) * [`66e5fa0`](openrewrite/rewrite-testing-frameworks@66e5fa0) OpenRewrite recipe best practices * [`c50e581`](openrewrite/rewrite-testing-frameworks@c50e581) Update Gradle wrapper to 9.7.0 * [`96ec8d6`](openrewrite/rewrite-testing-frameworks@96ec8d6) Do not convert constructors of types nested in a parameterized test class ([#1](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1)... * [`3ce54bc`](openrewrite/rewrite-testing-frameworks@3ce54bc) Add a blank line after the `mocks` field generated in Kotlin sources ([#1070](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1070)) * [`67a4c66`](openrewrite/rewrite-testing-frameworks@67a4c66) OpenRewrite recipe best practices * [`53fe08c`](openrewrite/rewrite-testing-frameworks@53fe08c) Emit `threadMode = SEPARATE_THREAD` when migrating `@Test(timeout = N)` ([#1076](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1076)) * [`fd1f3d8`](openrewrite/rewrite-testing-frameworks@fd1f3d8) Retain assertTrue/assertFalse(a.equals(null)) as is ([#1075](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1075)) * Additional commits viewable in [compare view](openrewrite/rewrite-testing-frameworks@v3.43.0...v3.44.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 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)
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.
Two
ChangePackagerules omitrecursivewhile depending on it, so types in subpackages ofoldPackageNamewere never migrated.I verified this against the published artifacts rather than guessing — every subpackage maps exactly under prefix substitution, so recursion is both safe and required:
datafaker.yml— javafaker 1.0.2 → datafaker 2.4.2com.github.javafaker.idnumbersnet.datafaker.idnumberscom.github.javafaker.servicenet.datafaker.servicecom.github.javafaker.service.filesnet.datafaker.service.filesassertj.yml— fest-assert-core 2.0M10 → assertj-core 3.26.3org.fest.assertions.api.filterorg.assertj.core.api.filterThe sibling
org.fest.assertions.utilandorg.fest.assertions.datarules are left alone — neither package has subpackages.Why the tests didn't catch this
ChangePackage.recursiveis@Nullablewithrequired = falseand no documented default, and a null was read two different ways inside the same recipe: non-recursive by its preconditions, recursive by its visitor. The upshot is that a subpackage type gets renamed only if the file also references a type sitting directly inoldPackageName— which every existing fixture happens to do. A real source file importing only the subpackage type was never migrated.recursiveconsistently mean non-recursive inChangePackagerewrite#8382 settles null as non-recursive, which is what surfaced it; I found this while auditing declarativeChangePackageusages against the published artifacts.Verification
./gradlew testgreen. Each new test fails without therecursive: trueline and passes with it. Correct on its own merits and safe to merge now, independently of rewrite#8382.