Skip to content

TestNgToAssertj: emit a static import for assertThat#1033

Merged
timtebeek merged 1 commit into
mainfrom
tim/testng-assertj-static-import
Jun 20, 2026
Merged

TestNgToAssertj: emit a static import for assertThat#1033
timtebeek merged 1 commit into
mainfrom
tim/testng-assertj-static-import

Conversation

@timtebeek

@timtebeek timtebeek commented Jun 20, 2026

Copy link
Copy Markdown
Member

TestNgToAssertj previously mirrored the source's qualification style: qualified Assert.assertX(...) calls became qualified Assertions.assertThat(...), while statically-imported calls stayed static-imported. A class that mixed both styles ended up with a mixed import form (import static ...assertThat and import ...Assertions).

This composes org.openrewrite.java.UseStaticImport for org.assertj.core.api.Assertions *(..) as a cleanup step, normalizing every AssertJ entry point the recipe introduces (assertThat, assertThatThrownBy, assertThatExceptionOfType, fail, …) to a static import — AssertJ's documented convention — regardless of the original TestNG qualification.

The broad Assertj recipe already ran StaticImports after TestNgToAssertj, so this only changes behavior when TestNgToAssertj runs standalone, which is what the issue reports.

Added a test exercising the standalone recipe on qualified Assert. calls.

Normalize the AssertJ entry points introduced by TestNgToAssertj to a
static import via UseStaticImport, so qualified Assert.assertX(...) calls
become static-imported assertThat(...) instead of mirroring the source
qualification as Assertions.assertThat(...).

Fixes #1029
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 20, 2026
@timtebeek timtebeek merged commit 54f3db8 into main Jun 20, 2026
1 check passed
@timtebeek timtebeek deleted the tim/testng-assertj-static-import branch June 20, 2026 11:56
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

TestNgToAssertj: emit a static import for assertThat instead of mirroring the source qualification (Assertions.assertThat)

1 participant