Skip to content

Comments

Fix 2 AssertJ migration recipe issues found via large-scale validation#914

Merged
timtebeek merged 1 commit intomainfrom
timtebeek/assertj-validate
Feb 21, 2026
Merged

Fix 2 AssertJ migration recipe issues found via large-scale validation#914
timtebeek merged 1 commit intomainfrom
timtebeek/assertj-validate

Conversation

@timtebeek
Copy link
Member

Summary

Fixed two issues discovered by running the AssertJ composite recipe against 12 real-world repositories (generating 4,139 patches):

  1. SimplifyRedundantAssertJChains: Don't drop isNotNull() before isNotEqualTo()/isNotSameAs() since these assertions pass when actual is null, making the null check not redundant. Found ~107 incorrect transformations in Spring Framework alone.

  2. TruthThrowableAssertions: Added handlers for 4 additional hasMessageThat() chains (containsMatch, doesNotContain, startsWith, endsWith) to prevent leaving Truth-only method calls that cause compilation errors.

Test Plan

  • All existing tests pass
  • New regression test prevents dropping isNotNull() before negated assertions
  • Four new tests validate the added Truth→AssertJ conversions

1. SimplifyRedundantAssertJChains: Don't drop isNotNull() before isNotEqualTo()/isNotSameAs()
   - These assertions pass when actual is null, so isNotNull() is not redundant
   - Found ~107 incorrect transformations in Spring Framework alone

2. TruthThrowableAssertions: Handle 4 additional hasMessageThat() chains
   - Added conversions for containsMatch, doesNotContain, startsWith, endsWith
   - Prevents leaving Truth-only methods that cause compilation errors
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 21, 2026
@timtebeek timtebeek merged commit 16f1501 into main Feb 21, 2026
1 check passed
@timtebeek timtebeek deleted the timtebeek/assertj-validate branch February 21, 2026 22:09
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant