diff --git a/api/server/pom.xml b/api/server/pom.xml
index 807a9d5..a04b0e3 100644
--- a/api/server/pom.xml
+++ b/api/server/pom.xml
@@ -1,126 +1,132 @@
4.0.0
org.softwareheritage.graph
graph
1.0-ALPHA
graph
https://www.softwareheritage.org/
UTF-8
11
junit
junit
4.11
test
+
+ org.hamcrest
+ hamcrest
+ 2.1
+ test
+
io.javalin
javalin
2.8.0
org.slf4j
slf4j-simple
1.7.26
com.fasterxml.jackson.core
jackson-databind
2.9.8
it.unimi.dsi
webgraph-big
3.5.0
it.unimi.dsi
fastutil
8.2.2
maven-clean-plugin
3.1.0
maven-resources-plugin
3.0.2
maven-compiler-plugin
3.8.0
-verbose
-Xlint:all
maven-surefire-plugin
2.22.1
maven-jar-plugin
3.0.2
maven-install-plugin
2.5.2
maven-deploy-plugin
2.8.2
maven-site-plugin
3.7.1
maven-project-info-reports-plugin
3.0.0
maven-assembly-plugin
org.softwareheritage.graph.App
jar-with-dependencies
make-assembly
package
single
diff --git a/api/server/src/test/java/org/softwareheritage/graph/VisitTest.java b/api/server/src/test/java/org/softwareheritage/graph/VisitTest.java
index 9ed036f..ad1f5a6 100644
--- a/api/server/src/test/java/org/softwareheritage/graph/VisitTest.java
+++ b/api/server/src/test/java/org/softwareheritage/graph/VisitTest.java
@@ -1,154 +1,159 @@
package org.softwareheritage.graph;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.GraphTest;
import org.softwareheritage.graph.SwhId;
import org.softwareheritage.graph.SwhPath;
import org.softwareheritage.graph.algo.Visit;
public class VisitTest extends GraphTest {
+ void assertEqualPaths(ArrayList expecteds, ArrayList actuals) {
+ Assert.assertThat(expecteds, containsInAnyOrder(actuals.toArray()));
+ }
+
@Test
public void dfsForwardFromRoot() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:dir:0000000000000000000000000000000000000001");
Visit visit = new Visit(graph, start, "all", "dfs", "forward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000009"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001",
"swh:1:cnt:0000000000000000000000000000000000000010"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:dir:0000000000000000000000000000000000000005",
"swh:1:cnt:0000000000000000000000000000000000000006"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:dir:0000000000000000000000000000000000000003",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
@Test
public void dfsForwardFromMiddle() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:dir:0000000000000000000000000000000000000002");
Visit visit = new Visit(graph, start, "all", "dfs", "forward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:dir:0000000000000000000000000000000000000005",
"swh:1:cnt:0000000000000000000000000000000000000006"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:dir:0000000000000000000000000000000000000003",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
@Test
public void dfsForwardFromLeaf() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:cnt:0000000000000000000000000000000000000006");
Visit visit = new Visit(graph, start, "all", "dfs", "forward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000006"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
@Test
public void dfsBackwardFromRoot() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:dir:0000000000000000000000000000000000000001");
Visit visit = new Visit(graph, start, "all", "dfs", "backward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000001"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
@Test
public void dfsBackwardFromMiddle() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:dir:0000000000000000000000000000000000000008");
Visit visit = new Visit(graph, start, "all", "dfs", "backward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000001"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
@Test
public void dfsBackwardFromLeaf() {
Graph graph = getGraph();
SwhId start = new SwhId("swh:1:cnt:0000000000000000000000000000000000000006");
Visit visit = new Visit(graph, start, "all", "dfs", "backward");
ArrayList paths = visit.getPaths();
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000005",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:dir:0000000000000000000000000000000000000001"
));
- Assert.assertEquals(expectedPaths, paths);
+ assertEqualPaths(expectedPaths, paths);
}
}