Skip to content

Use flexible version assertions in ChangeDependencyGroupIdAndArtifactId tests#6799

Merged
Jenson3210 merged 3 commits intomainfrom
fix-dependency-gavid-test-versions
Feb 23, 2026
Merged

Use flexible version assertions in ChangeDependencyGroupIdAndArtifactId tests#6799
Jenson3210 merged 3 commits intomainfrom
fix-dependency-gavid-test-versions

Conversation

@Jenson3210
Copy link
Copy Markdown
Contributor

Summary

  • Switch 3 tests in ChangeDependencyGroupIdAndArtifactIdTest from hardcoded version assertions to dynamic pattern matching using spec.after() with regex and AssertJ

Problem

Three tests fail because they assert <version>2.21.0</version> for jackson-jakarta-rs-json-provider, but the 2.x version pattern now resolves to 2.21.1 on Maven Central. These tests break every time a new Jackson 2.x version is published.

Solution

Use the established spec.after(after -> { ... }) callback pattern (already used in UpgradeDependencyVersionTest and others) to:

  1. Extract the actual resolved version from the output XML using regex
  2. Assert it matches 2.\d+.\d+ via AssertJ
  3. Return the expected XML with the extracted version interpolated

Tests fixed:

  • versionNotDroppedWhenDependencyExcludedByOtherDependency
  • versionNotDroppedWhenTransitiveDependencyHasManagedVersion
  • exclusionUpdatedWhenDependencyGroupIdChanges

Test plan

  • All 55 tests in ChangeDependencyGroupIdAndArtifactIdTest pass
  • No other changes outside the test file

…IdTest

Three tests were failing because they hardcoded version 2.21.0 for
jackson-jakarta-rs-json-provider, but Maven Central now resolves 2.x
to 2.21.1. Switch to using spec.after() with regex pattern matching
to extract and validate the resolved version dynamically.
Jenson3210 and others added 2 commits February 23, 2026 14:46
Use the preferred fluent AssertJ pattern that combines groupId,
artifactId and version assertions into a single containsPattern call.
Copy link
Copy Markdown
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 a lot! Nice not to have to maintain these anymore with new releases.

@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Feb 23, 2026
@Jenson3210 Jenson3210 merged commit d4392fc into main Feb 23, 2026
1 check passed
@Jenson3210 Jenson3210 deleted the fix-dependency-gavid-test-versions branch February 23, 2026 14:30
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Feb 23, 2026
knutwannheden added a commit that referenced this pull request Apr 27, 2026
ChangeDependencyGroupIdAndArtifactIdTest.noDependencyManagementSection
hardcoded the post-recipe junit-jupiter version as 5.14.3, but the
recipe resolves "5.x" against Maven Central at runtime. Every new
junit-jupiter 5.x patch release breaks CI for every PR until someone
bumps the literal. The most recent break is 5.14.4, published earlier
today.

Switch the assertion to a regex pattern matching any 5.x.x release,
following the convention established in #6799 / #6856.
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.

2 participants