JackPGreen commented on code in PR #1597:
URL:
https://github.com/apache/maven-dependency-plugin/pull/1597#discussion_r3006270276
##########
src/test/java/org/apache/maven/plugins/dependency/exclusion/AnalyzeExclusionsMojoTest.java:
##########
@@ -85,9 +83,7 @@ void setUp() {
when(project.getArtifactId()).thenReturn("testArtifactId");
when(project.getVersion()).thenReturn("1.0.0");
- DependencyManagement dependencyManagement =
mock(DependencyManagement.class);
-
when(dependencyManagement.getDependencies()).thenReturn(Collections.emptyList());
-
when(project.getDependencyManagement()).thenReturn(dependencyManagement);
+ when(project.getDependencyManagement()).thenReturn(null);
Review Comment:
> I think the existing tests should still work without changes. You need to
add a new test that specifically addresses the null case.
I did originally try to add a new explicit test case to cover this, but I
realised the real issue is the mock test fixture is the real issue.
In the test we are mocking `getDependencyManagement()` to always return a
non-`null` value - but the documentation offers no non-`null` guarantees and
indeed some other internal Maven code is checking for `null` from this methods'
invocation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]