-
Notifications
You must be signed in to change notification settings - Fork 2.8k
tests(maven#10389): Adding DefaultDependencyResolverResultTest #11410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
tests(maven#10389): Adding DefaultDependencyResolverResultTest #11410
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be easier to use org.apache.maven.impl.resolver.type.DefaultType instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a method or constants instead of those long calls to the constructors.
d76590a to
dafad48
Compare
Came up with a reusable method. |
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.