diff --git a/README.md b/README.md index 8a950b3..f6b076d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ mvn com.jfrog:maven-dep-tree:tree -DdepsTreeOutputFile= "children": [], "configurations": [ "test" + ], + "types": [ + "jar" ] }, "org.jfrog.test:multi:3.7-SNAPSHOT": { @@ -55,7 +58,9 @@ mvn com.jfrog:maven-dep-tree:tree -DdepsTreeOutputFile= "junit:junit:3.8.1" ], "configurations": [], - "types": ["jar"] + "types": [ + "jar" + ] } } } diff --git a/src/main/java/com/jfrog/mavendeptree/dependenciesresults/MavenDependencyNode.java b/src/main/java/com/jfrog/mavendeptree/dependenciesresults/MavenDependencyNode.java index d7d5651..cef2f17 100644 --- a/src/main/java/com/jfrog/mavendeptree/dependenciesresults/MavenDependencyNode.java +++ b/src/main/java/com/jfrog/mavendeptree/dependenciesresults/MavenDependencyNode.java @@ -38,7 +38,7 @@ public void addConfiguration(String configuration) { } public void addType(String type) { - configurations.add(type); + types.add(type); } @Override diff --git a/src/test/java/com/jfrog/mavendeptree/UtilsTests.java b/src/test/java/com/jfrog/mavendeptree/UtilsTests.java index 0c17802..db5295d 100644 --- a/src/test/java/com/jfrog/mavendeptree/UtilsTests.java +++ b/src/test/java/com/jfrog/mavendeptree/UtilsTests.java @@ -24,22 +24,22 @@ public class UtilsTests { @Test public void testPopulateDependencyMapNoChildren() { - DependencyNode root = createDependency("root-group", "root-artifact", "root-version", null); + DependencyNode root = createDependency("root-group", "root-artifact", "root-version", null,""); runPopulateDependencyMap(root, 1); } @Test public void testPopulateDependencyMapDuplicateChildren() { - DefaultDependencyNode root = createDependency("root-group", "root-artifact", "root-version", null); + DefaultDependencyNode root = createDependency("root-group", "root-artifact", "root-version", null,""); // Root's children - DefaultDependencyNode firstChild = createDependency("child1-group", "child1-artifact", "child1-version", "scope1"); - DefaultDependencyNode secondChild = createDependency("child2-group", "child2-artifact", "child2-version", "scope2"); + DefaultDependencyNode firstChild = createDependency("child1-group", "child1-artifact", "child1-version", "scope1",""); + DefaultDependencyNode secondChild = createDependency("child2-group", "child2-artifact", "child2-version", "scope2","type2"); root.setChildren(Lists.newArrayList(firstChild, secondChild)); // First child's children - DefaultDependencyNode thirdChild = createDependency("child3-group", "child3-artifact", "child3-version", "scope3"); - DefaultDependencyNode secondsChildWithOtherScope = createDependency("child2-group", "child2-artifact", "child2-version", "other-scope"); + DefaultDependencyNode thirdChild = createDependency("child3-group", "child3-artifact", "child3-version", "scope3",""); + DefaultDependencyNode secondsChildWithOtherScope = createDependency("child2-group", "child2-artifact", "child2-version", "other-scope","other-type"); firstChild.setChildren(Lists.newArrayList(secondsChildWithOtherScope, thirdChild)); @@ -60,20 +60,21 @@ public void testPopulateDependencyMapDuplicateChildren() { assertNotNull(secondChildNode); assertEquals(secondChildNode.getChildren(), new HashSet<>()); assertEquals(secondChildNode.getConfigurations(), Sets.newHashSet("scope2", "other-scope")); + assertEquals(secondChildNode.getTypes(), Sets.newHashSet("type2", "other-type")); } @Test public void testGetNodeId() { - Artifact artifact = createArtifact("group", "artifact", "1.0.0", "scope"); + Artifact artifact = createArtifact("group", "artifact", "1.0.0", "scope",""); assertEquals(getGavString(artifact), "group:artifact:1.0.0"); } - private Artifact createArtifact(String groupId, String artifactId, String version, String scope) { - return new DefaultArtifact(groupId, artifactId, version, scope, "", "", null); + private Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) { + return new DefaultArtifact(groupId, artifactId, version, scope, type, "", null); } - private DefaultDependencyNode createDependency(String groupId, String artifactId, String version, String scope) { - Artifact artifact = createArtifact(groupId, artifactId, version, scope); + private DefaultDependencyNode createDependency(String groupId, String artifactId, String version, String scope,String type) { + Artifact artifact = createArtifact(groupId, artifactId, version, scope,type); return new DefaultDependencyNode(artifact); } diff --git a/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java b/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java index 74cf3f8..1960e6c 100644 --- a/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java +++ b/src/test/java/com/jfrog/mavendeptree/integration/MavenDepTreeITest.java @@ -68,7 +68,7 @@ public void testMultiModule() throws VerificationException, IOException, ParserC assertEquals(root, "org.jfrog.test:multi3:3.7-SNAPSHOT"); } else { assertEquals(root, "org.jfrog.test:multi:3.7-SNAPSHOT"); - assertEquals(mavenDependencyTree.getNodes().get("junit:junit:3.8.1"), new MavenDependencyNode("test")); + assertEquals(mavenDependencyTree.getNodes().get("junit:junit:3.8.1"), new MavenDependencyNode("test","jar")); } } } @@ -102,7 +102,7 @@ private void testMavenArchetype(String projectName) throws VerificationException MavenDependencyNode expectedFirstNode = new MavenDependencyNode(); expectedFirstNode.addChild("junit:junit:3.8.1"); assertEquals(nodes.get("org.example:maven-archetype-simple:1.0-SNAPSHOT"), expectedFirstNode); - MavenDependencyNode expectedSecondNode = new MavenDependencyNode("test"); + MavenDependencyNode expectedSecondNode = new MavenDependencyNode("test","jar"); assertEquals(nodes.get("junit:junit:3.8.1"), expectedSecondNode); } }