tests(maven#10389): Adding DefaultDependencyResolverResultTest#11410
tests(maven#10389): Adding DefaultDependencyResolverResultTest#11410vijaykriishna wants to merge 1 commit intoapache:masterfrom
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Using DefaultType will remove 150 lines of code and will make the test more readable.
| Dependency dep = mock(Dependency.class); | ||
| when(dep.getGroupId()).thenReturn("g"); | ||
| when(dep.getArtifactId()).thenReturn("a"); | ||
| when(dep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
It may be easier to use org.apache.maven.impl.resolver.type.DefaultType instead.
There was a problem hiding this comment.
It may be easier to use
org.apache.maven.impl.resolver.type.DefaultTypeinstead.
Done.
| Dependency dep = mock(Dependency.class); | ||
| when(dep.getGroupId()).thenReturn("g"); | ||
| when(dep.getArtifactId()).thenReturn("a"); | ||
| when(dep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Path p = Files.createTempFile("unres", ".jar"); | ||
|
|
||
| // Type returns a known CLASSES and an unknown custom PathType => selectPathType should return empty | ||
| when(dep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Dependency dep = mock(Dependency.class); | ||
| when(dep.getGroupId()).thenReturn("g3"); | ||
| when(dep.getArtifactId()).thenReturn("a3"); | ||
| when(dep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Dependency dep1 = mock(Dependency.class); | ||
| when(dep1.getGroupId()).thenReturn("g1"); | ||
| when(dep1.getArtifactId()).thenReturn("a1"); | ||
| when(dep1.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Dependency dep2 = mock(Dependency.class); | ||
| when(dep2.getGroupId()).thenReturn("g2"); | ||
| when(dep2.getArtifactId()).thenReturn("a2"); | ||
| when(dep2.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Dependency mainDep = mock(Dependency.class); | ||
| when(mainDep.getGroupId()).thenReturn("gX"); | ||
| when(mainDep.getArtifactId()).thenReturn("aX"); | ||
| when(mainDep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
| Dependency patchDep = mock(Dependency.class); | ||
| when(patchDep.getGroupId()).thenReturn("gX"); | ||
| when(patchDep.getArtifactId()).thenReturn("aX"); // same identifiers -> findArtifactPath should find mainDep | ||
| when(patchDep.getType()).thenReturn(new org.apache.maven.api.Type() { |
There was a problem hiding this comment.
Same...
Done.
849ec97 to
d0db7d2
Compare
Done. |
| when(dep.getArtifactId()).thenReturn("a"); | ||
| when(dep.getType()) | ||
| .thenReturn(new DefaultType( | ||
| "jar", org.apache.maven.api.Language.JAVA_FAMILY, "jar", null, false, JavaPathType.MODULES)); |
There was a problem hiding this comment.
Consider using a method createJarType(JavaPathType.MODULES) that can be reused at the 5 locations. Alternatively, using constants could work too.
There was a problem hiding this comment.
Consider using a method
createJarType(JavaPathType.MODULES)that can be reused at the 5 locations. Alternatively, using constants could work too.
Came up with a reusable method.
gnodet
left a comment
There was a problem hiding this comment.
Use a method or constants instead of those long calls to the constructors.
d76590a to
dafad48
Compare
Came up with a reusable method. |
|
Please fix the formatting. |
dafad48 to
9a9bdb1
Compare
oops missed it. Noted. Formatted the code using |
Title: [https://github.com//issues/10389] tests(maven#10389): Adding DefaultDependencyResolverResultTest
Added unit tests for DefaultDependencyResolverResult
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.