@Test public void run() throws Exception { final URI source = sourceURI(); final ProjectVersionRef root = projectVersion("group.id", "my-project", "1.0"); final ProjectVersionRef d1 = projectVersion("other.group", "dep-L1", "1.0.1"); final ProjectVersionRef d2 = projectVersion("foo", "dep-L2", "1.1.1"); final ProjectVersionRef d3 = projectVersion("foo", "dep-L2", "1.1.2"); RelationshipGraph graph = simpleGraph(root); /* @formatter:off */ graph.storeRelationships( new SimpleParentRelationship(source, root), new SimpleDependencyRelationship( source, root, d1.asJarArtifact(), compile, 0, false, false, false), new SimpleDependencyRelationship( source, d1, d2.asJarArtifact(), compile, 0, false, false, false)); /* @formatter:on */ graph = graphFactory() .open( new ViewParams.Builder(graph.getParams()) .withSelection(d2.asProjectRef(), d3) .build(), false); // graph.getView() // .selectVersion( d2.asProjectRef(), d3 ); final TransitiveDependencyTraversal depTraversal = new TransitiveDependencyTraversal(); graph.traverse(depTraversal); final List<ArtifactRef> artifacts = depTraversal.getArtifacts(); assertThat(artifacts.size(), equalTo(2)); int idx = 0; ArtifactRef ref = artifacts.get(idx++); assertThat(ref.getArtifactId(), equalTo("dep-L1")); ref = artifacts.get(idx++); assertThat(ref.getArtifactId(), equalTo("dep-L2")); assertThat(ref.getVersionString(), equalTo(d3.getVersionString())); }
public String getVersion() { return key.getVersionString(); }