Skip to content
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

[MRESOLVER-376] UT for bug #312

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,23 @@ public void testTransitiveDepsUseRangesDirtyTree() throws DependencyCollectionEx

protected abstract String getTransitiveDepsUseRangesDirtyTreeResource();

@Test
public void testTransitiveDepsUseRangesAndRelocationDirtyTree() throws DependencyCollectionException, IOException {
// Note: DF depends on version order (ultimately the order of versions as returned by VersionRangeResolver
// that in case of Maven, means order as in maven-metadata.xml
// BF on the other hand explicitly sorts versions from range in descending order
//
// Hence, the "dirty tree" of two will not match.
DependencyNode root = parser.parseResource(getTransitiveDepsUseRangesAndRelocationDirtyTreeResource());
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, singletonList(repository));

CollectResult result = collector.collectDependencies(session, request);
assertEqualSubtree(root, result.getRoot());
}

protected abstract String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource();

private DependencyNode toDependencyResult(
final DependencyNode root, final String rootScope, final Boolean optional) {
// Make the root artifact resultion result a dependency resolution result for the subtree check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ protected String getTransitiveDepsUseRangesDirtyTreeResource() {
return "transitiveDepsUseRangesDirtyTreeResult_BF.txt";
}

@Override
protected String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource() {
return "transitiveDepsUseRangesAndRelocationDirtyTreeResult_BF.txt";
}

private Dependency newDep(String coords, String scope, Collection<Exclusion> exclusions) {
Dependency d = new Dependency(new DefaultArtifact(coords), scope);
return d.setExclusions(exclusions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ protected void setupCollector() {
protected String getTransitiveDepsUseRangesDirtyTreeResource() {
return "transitiveDepsUseRangesDirtyTreeResult_DF.txt";
}

@Override
protected String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource() {
return "transitiveDepsUseRangesAndRelocationDirtyTreeResult_DF.txt";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transitiveDepsUseRangesAndRelocationDirtyTree:aid:ext:1 compile
+- transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:3 compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transitiveDepsUseRangesAndRelocationDirtyTree:aid:ext:1 compile
\- transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:1 compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
transitiveDepsUseRangesAndRelocationDirtyTree:cid:ext:[1,3]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:1

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:2

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:3

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ArtifactDescriptorResult readArtifactDescriptor(
ArtifactDescription data = reader.parse(resourceName);
if (data.getRelocation() != null) {
result.addRelocation(artifact);
result.setArtifact(data.getRelocation());
artifact = data.getRelocation();
} else {
result.setArtifact(artifact);
Expand Down
Loading