Skip to content

Added additional tests to ProjectModelResolverTest - #11502

Open
TheRealHaui wants to merge 1 commit into
apache:masterfrom
TheRealHaui:add-tests-to-ProjectModelResolverTest
Open

Added additional tests to ProjectModelResolverTest#11502
TheRealHaui wants to merge 1 commit into
apache:masterfrom
TheRealHaui:add-tests-to-ProjectModelResolverTest

Conversation

@TheRealHaui

Copy link
Copy Markdown
Contributor

Added additional tests to ProjectModelResolverTest

@cstamas

cstamas commented Nov 28, 2025

Copy link
Copy Markdown
Member

LGTM. @gnodet ?

@gnodet gnodet added the mvn4 label Jun 22, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: Added additional tests to ProjectModelResolverTest

Good addition — these tests exercise a meaningful error path: what happens when a user provides a syntactically invalid version range (: instead of , as separator). This covers the catch (VersionRangeResolutionException e) branch in ProjectModelResolver.resolveModel() that was previously untested. The throws Exception cleanup is also a nice touch.

The tests follow the existing conventions in the file (JUnit 5 Assertions, consistent naming, matching parent/dependency test pairs). @cstamas has already given an LGTM.

Observations

Low — Full message assertions depend on Aether library text

The assertions use assertEquals on the full exception message string:

"Failed to resolve version range for org.apache:apache:pom:[1:2): Invalid version range [1:2), single version must be surrounded by []"

This entire message originates from the Aether VersionRangeResolutionException — Maven just passes it through via e.getMessage(). If the resolver library changes this wording, the test breaks for reasons unrelated to Maven.

The existing tests in this file that use assertEquals assert on messages that Maven itself constructs (the String.format(...) calls at lines 197-198 and 209-210 of ProjectModelResolver.java). The one existing test that checks a message from an external library (testResolve*WhenNotFound) uses assertTrue(contains(...)) instead of assertEquals.

For consistency and resilience, consider assertTrue(e.getMessage().contains("Invalid version range")) or assertThat(e.getMessage()).contains("Invalid version range").

This is a minor observation — the tests are correct and useful as-is.


This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

gnodet added a commit to gnodet/maven that referenced this pull request Jul 10, 2026
Reviewed 3 PRs: apache#12454 (re-review), apache#11502 (new), apache#11405 (new).
Added 2 new dependabot PRs to skip list.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean test-only PR that adds two new test cases covering the malformed version range error path in ProjectModelResolver and removes unnecessary throws Exception declarations from six existing test methods. All changes are correct and follow the file's existing conventions.

One minor observation: the assertEquals assertions check the full exception message string from VersionRangeResolutionException. If Aether changes this wording, these tests would break. Consider using assertTrue(e.getMessage().contains("Invalid version range")) for resilience — though the tests are correct as-is. (Already noted by a prior reviewer.)

CI is fully green (the single macOS+JDK17 IT failure is unrelated).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

@slachiewicz

Copy link
Copy Markdown
Member

The last CI run on this branch was 2025-11-28, and GitHub has deleted the logs since, so there's no way to tell whether the change still builds against master.

A rebase triggers a fresh run and makes the state readable again. If you'd rather not carry it forward, closing is equally useful — the PR isn't being ignored, it's unreadable.

This comment was created with AI assistance.

@slachiewicz slachiewicz added the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Aug 24, 2026
@TheRealHaui

Copy link
Copy Markdown
Contributor Author

@slachiewicz,
I think the only thing necessary to do here is to re-start the CI builds.

@github-actions github-actions Bot removed the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Aug 31, 2026
@slachiewicz

Copy link
Copy Markdown
Member

I can't trigger it as it's old run and it's possible only for 30 days since last run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants