1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.collect.bf;
20
21 import java.util.*;
22
23 import org.eclipse.aether.artifact.DefaultArtifact;
24 import org.eclipse.aether.collection.CollectRequest;
25 import org.eclipse.aether.collection.CollectResult;
26 import org.eclipse.aether.collection.DependencyCollectionException;
27 import org.eclipse.aether.graph.Dependency;
28 import org.eclipse.aether.graph.Exclusion;
29 import org.eclipse.aether.impl.ArtifactDescriptorReader;
30 import org.eclipse.aether.internal.impl.StubRemoteRepositoryManager;
31 import org.eclipse.aether.internal.impl.StubVersionRangeResolver;
32 import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
33 import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegateTestSupport;
34 import org.eclipse.aether.internal.test.util.DependencyGraphParser;
35 import org.eclipse.aether.util.graph.manager.TransitiveDependencyManager;
36 import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
37 import org.junit.jupiter.api.Test;
38
39 import static org.junit.jupiter.api.Assertions.assertEquals;
40
41
42
43
44 public class BfWithSkipperDependencyCollectorTest extends DependencyCollectorDelegateTestSupport {
45 @Override
46 protected DependencyCollectorDelegate setupCollector(ArtifactDescriptorReader artifactDescriptorReader) {
47 session.setConfigProperty(BfDependencyCollector.CONFIG_PROP_SKIPPER, true);
48
49 return new BfDependencyCollector(
50 new StubRemoteRepositoryManager(),
51 artifactDescriptorReader,
52 new StubVersionRangeResolver(),
53 Collections.emptyMap());
54 }
55
56 @Override
57 protected String getTransitiveDepsUseRangesDirtyTreeResource() {
58 return "transitiveDepsUseRangesDirtyTreeResult_BF.txt";
59 }
60
61 @Override
62 protected String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource() {
63 return "transitiveDepsUseRangesAndRelocationDirtyTreeResult_BF.txt";
64 }
65
66 private Dependency newDep(String coords, String scope, Collection<Exclusion> exclusions) {
67 Dependency d = new Dependency(new DefaultArtifact(coords), scope);
68 return d.setExclusions(exclusions);
69 }
70
71 @Test
72 void testSkipperWithDifferentExclusion() throws DependencyCollectionException {
73 collector = setupCollector(newReader("managed/"));
74 parser = new DependencyGraphParser("artifact-descriptions/managed/");
75 session.setDependencyManager(new TransitiveDependencyManager(null));
76
77 ExclusionDependencySelector exclSel1 = new ExclusionDependencySelector();
78 session.setDependencySelector(exclSel1);
79
80 Dependency root1 = newDep(
81 "gid:root:ext:ver", "compile", Collections.singleton(new Exclusion("gid", "transitive-1", "", "ext")));
82 Dependency root2 = newDep(
83 "gid:root:ext:ver", "compile", Collections.singleton(new Exclusion("gid", "transitive-2", "", "ext")));
84 List<Dependency> dependencies = Arrays.asList(root1, root2);
85
86 CollectRequest request = new CollectRequest(dependencies, null, Collections.singletonList(repository));
87 request.addManagedDependency(newDep("gid:direct:ext:managed-by-dominant-request"));
88 request.addManagedDependency(newDep("gid:transitive-1:ext:managed-by-root"));
89
90 CollectResult result = collector.collectDependencies(session, request);
91 assertEquals(0, result.getExceptions().size());
92 assertEquals(2, result.getRoot().getChildren().size());
93 assertEquals(root1, dep(result.getRoot(), 0));
94 assertEquals(root2, dep(result.getRoot(), 1));
95
96 assertEquals(1, path(result.getRoot(), 0).getChildren().size());
97 assertEquals(0, path(result.getRoot(), 0, 0).getChildren().size());
98
99 assertEquals(0, path(result.getRoot(), 1).getChildren().size());
100 }
101 }