Skip to content

Commit

Permalink
fix readme and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asafambar committed Dec 27, 2023
1 parent 901ce3a commit 337b2b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ mvn com.jfrog:maven-dep-tree:tree -DdepsTreeOutputFile=<path/to/output/file>
"children": [],
"configurations": [
"test"
],
"types": [
"jar"
]
},
"org.jfrog.test:multi:3.7-SNAPSHOT": {
"children": [
"junit:junit:3.8.1"
],
"configurations": [],
"types": ["jar"]
"types": [
"jar"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void addConfiguration(String configuration) {
}

public void addType(String type) {
configurations.add(type);
types.add(type);
}

@Override
Expand Down
23 changes: 12 additions & 11 deletions src/test/java/com/jfrog/mavendeptree/UtilsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 337b2b6

Please sign in to comment.