Page MenuHomeSoftware Heritage

No OneTemporary

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/java/server/src/main/java/org/softwareheritage/graph/Node.java b/java/server/src/main/java/org/softwareheritage/graph/Node.java
index a883737..b2a532b 100644
--- a/java/server/src/main/java/org/softwareheritage/graph/Node.java
+++ b/java/server/src/main/java/org/softwareheritage/graph/Node.java
@@ -1,86 +1,93 @@
package org.softwareheritage.graph;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* A node in the Software Heritage graph.
*
* @author Thibault Allançon
* @version 1.0
* @since 1.0
*/
public class Node {
/**
* Software Heritage graph node types, as described in the
* <a href="https://docs.softwareheritage.org/devel/swh-model/data-model.html">data model</a>.
*/
public enum Type {
/** Content node */
CNT,
/** Directory node */
DIR,
+ /** Origin node */
+ ORI,
/** Release node */
REL,
/** Revision node */
REV,
/** Snapshot node */
SNP;
/**
* Converts integer to corresponding SWH node type.
*
* @param intType node type represented as an integer
* @return the corresponding {@link Node.Type} value
* @see org.softwareheritage.graph.Node.Type
*/
public static Node.Type fromInt(int intType) {
switch (intType) {
case 0:
return CNT;
case 1:
return DIR;
case 2:
- return REL;
+ return ORI;
case 3:
- return REV;
+ return REL;
case 4:
+ return REV;
+ case 5:
return SNP;
}
return null;
}
/**
* Parses SWH node type from string.
*
* @param strType node type represented as a string
* @return the corresponding {@link Node.Type} value
* @see org.softwareheritage.graph.Node.Type
*/
public static Node.Type fromStr(String strType) {
+ if (!strType.matches("cnt|dir|ori|rel|rev|snp")) {
+ throw new IllegalArgumentException("Unknown node type: " + strType);
+ }
return Node.Type.valueOf(strType.toUpperCase());
}
/**
* Parses SWH node type possible values from formatted string (TODO: link API doc).
*
* @param strFmtType node types represented as a formatted string (TODO: link API doc)
* @return a list containing the {@link Node.Type} values
* @see org.softwareheritage.graph.Node.Type
*/
public static ArrayList<Node.Type> parse(String strFmtType) {
ArrayList<Node.Type> types = new ArrayList<>();
if (strFmtType.equals("*")) {
List<Node.Type> nodeTypes = Arrays.asList(Node.Type.values());
types.addAll(nodeTypes);
} else {
types.add(Node.Type.fromStr(strFmtType));
}
return types;
}
}
}
diff --git a/java/server/src/main/java/org/softwareheritage/graph/SwhId.java b/java/server/src/main/java/org/softwareheritage/graph/SwhId.java
index 5e70e1b..172148f 100644
--- a/java/server/src/main/java/org/softwareheritage/graph/SwhId.java
+++ b/java/server/src/main/java/org/softwareheritage/graph/SwhId.java
@@ -1,101 +1,97 @@
package org.softwareheritage.graph;
import com.fasterxml.jackson.annotation.JsonValue;
import org.softwareheritage.graph.Node;
/**
* A Software Heritage PID, see <a
* href="https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html#persistent-identifiers">persistent
* identifier documentation</a>.
*
* @author Thibault Allançon
* @version 1.0
* @since 1.0
*/
public class SwhId {
/** Fixed hash length of the PID */
public static final int HASH_LENGTH = 40;
/** Full PID as a string */
String swhId;
/** PID node type */
Node.Type type;
/** PID hex-encoded SHA1 hash */
String hash;
/**
* Constructor.
*
* @param swhId full PID as a string
*/
public SwhId(String swhId) {
this.swhId = swhId;
// PID format: 'swh:1:type:hash'
String[] parts = swhId.split(":");
if (parts.length != 4 || !parts[0].equals("swh") || !parts[1].equals("1")) {
throw new IllegalArgumentException("Expected SWH ID format to be 'swh:1:type:hash', got: " + swhId);
}
- String type = parts[2];
- if (!type.matches("cnt|dir|rel|rev|snp")) {
- throw new IllegalArgumentException("Unknown SWH ID type in: " + swhId);
- }
- this.type = Node.Type.fromStr(type);
+ this.type = Node.Type.fromStr(parts[2]);
this.hash = parts[3];
if (!hash.matches("[0-9a-f]{" + HASH_LENGTH + "}")) {
throw new IllegalArgumentException("Wrong SWH ID hash format in: " + swhId);
}
}
@Override
public boolean equals(Object otherObj) {
if (otherObj == this) return true;
if (!(otherObj instanceof SwhId)) return false;
SwhId other = (SwhId) otherObj;
return swhId.equals(other.getSwhId());
}
@Override
public int hashCode() {
return swhId.hashCode();
}
@Override
public String toString() {
return swhId;
}
/**
* Returns full PID as a string.
*
* @return full PID string
*/
@JsonValue
public String getSwhId() {
return swhId;
}
/**
* Returns PID node type.
*
* @return PID corresponding {@link Node.Type}
* @see org.softwareheritage.graph.Node.Type
*/
public Node.Type getType() {
return type;
}
/**
* Returns PID hex-encoded SHA1 hash.
*
* @return PID string hash
*/
public String getHash() {
return hash;
}
}
diff --git a/java/server/src/test/dataset/example.edges.csv b/java/server/src/test/dataset/example.edges.csv
index 9e6ef6b..a91c083 100644
--- a/java/server/src/test/dataset/example.edges.csv
+++ b/java/server/src/test/dataset/example.edges.csv
@@ -1,22 +1,23 @@
swh:1:dir:0000000000000000000000000000000000000002 swh:1:cnt:0000000000000000000000000000000000000001
swh:1:rev:0000000000000000000000000000000000000003 swh:1:dir:0000000000000000000000000000000000000002
swh:1:dir:0000000000000000000000000000000000000008 swh:1:cnt:0000000000000000000000000000000000000001
swh:1:dir:0000000000000000000000000000000000000008 swh:1:dir:0000000000000000000000000000000000000006
swh:1:dir:0000000000000000000000000000000000000006 swh:1:cnt:0000000000000000000000000000000000000004
swh:1:dir:0000000000000000000000000000000000000006 swh:1:cnt:0000000000000000000000000000000000000005
swh:1:dir:0000000000000000000000000000000000000008 swh:1:cnt:0000000000000000000000000000000000000007
swh:1:rev:0000000000000000000000000000000000000009 swh:1:dir:0000000000000000000000000000000000000008
swh:1:rel:0000000000000000000000000000000000000010 swh:1:rev:0000000000000000000000000000000000000009
swh:1:rev:0000000000000000000000000000000000000009 swh:1:rev:0000000000000000000000000000000000000003
swh:1:dir:0000000000000000000000000000000000000012 swh:1:cnt:0000000000000000000000000000000000000011
swh:1:dir:0000000000000000000000000000000000000012 swh:1:dir:0000000000000000000000000000000000000008
swh:1:rev:0000000000000000000000000000000000000013 swh:1:dir:0000000000000000000000000000000000000012
swh:1:rev:0000000000000000000000000000000000000013 swh:1:rev:0000000000000000000000000000000000000009
swh:1:dir:0000000000000000000000000000000000000017 swh:1:cnt:0000000000000000000000000000000000000014
swh:1:dir:0000000000000000000000000000000000000017 swh:1:dir:0000000000000000000000000000000000000016
swh:1:dir:0000000000000000000000000000000000000016 swh:1:cnt:0000000000000000000000000000000000000015
swh:1:rev:0000000000000000000000000000000000000018 swh:1:dir:0000000000000000000000000000000000000017
swh:1:rev:0000000000000000000000000000000000000018 swh:1:rev:0000000000000000000000000000000000000013
swh:1:rel:0000000000000000000000000000000000000019 swh:1:rev:0000000000000000000000000000000000000018
swh:1:snp:0000000000000000000000000000000000000020 swh:1:rev:0000000000000000000000000000000000000009
swh:1:snp:0000000000000000000000000000000000000020 swh:1:rel:0000000000000000000000000000000000000010
+swh:1:ori:0000000000000000000000000000000000000021 swh:1:snp:0000000000000000000000000000000000000020
diff --git a/java/server/src/test/dataset/img/example.dot b/java/server/src/test/dataset/img/example.dot
index 80460a7..d1bdb1f 100644
--- a/java/server/src/test/dataset/img/example.dot
+++ b/java/server/src/test/dataset/img/example.dot
@@ -1,74 +1,82 @@
digraph "Software Heritage mini DAG" {
ranksep=1;
nodesep=0.5;
subgraph cnt {
01 [label="cnt:0x01"];
04 [label="cnt:0x04"];
05 [label="cnt:0x05"];
07 [label="cnt:0x07"];
11 [label="cnt:0x11"];
14 [label="cnt:0x14"];
15 [label="cnt:0x15"];
}
subgraph cluster_dir {
label="File contents";
node [shape=folder];
02 [label="dir:0x02"];
06 [label="dir:0x06"];
08 [label="dir:0x08"];
12 [label="dir:0x12"];
16 [label="dir:0x16"];
17 [label="dir:0x17"];
02 -> 01;
06 -> 04;
06 -> 05;
08 -> 01;
08 -> 06;
08 -> 07;
12 -> 08;
12 -> 11;
16 -> 15;
17 -> 14;
17 -> 16;
}
subgraph cluster_rev {
label="Revisions";
node [shape=diamond];
03 [label="rev:0x03"];
09 [label="rev:0x09"];
13 [label="rev:0x13"];
18 [label="rev:0x18"];
03 -> 02;
09 -> 08;
13 -> 12;
18 -> 17;
// horizontal rev -> rev edges
09 -> 03 [constraint=false];
13 -> 09 [constraint=false];
18 -> 13 [constraint=false];
}
subgraph cluster_rel {
label="Releases";
node [shape=octagon];
10 [label="rel:0x10"];
19 [label="rel:0x19"];
10 -> 09;
19 -> 18;
}
subgraph cluster_snp {
label="Snapshots";
node [shape=doubleoctagon];
20 [label="snp:0x20"];
20 -> 09;
20 -> 10;
}
+
+ subgraph cluster_ori {
+ label="Origins";
+ node [shape=egg];
+ 21 [label="ori:0x21"];
+
+ 21 -> 20;
+ }
}
diff --git a/java/server/src/test/dataset/output/example-transposed.graph b/java/server/src/test/dataset/output/example-transposed.graph
index 557fda2..c32d5d9 100644
--- a/java/server/src/test/dataset/output/example-transposed.graph
+++ b/java/server/src/test/dataset/output/example-transposed.graph
@@ -1 +1 @@
-®—I¯'ÉâR_?¢REïîJI­ñ5Ü
\ No newline at end of file
+[:é5Ñ5YK¦ë+Çä_&¼Nº]/W«¥Ü
\ No newline at end of file
diff --git a/java/server/src/test/dataset/output/example-transposed.obl b/java/server/src/test/dataset/output/example-transposed.obl
index ad43bdb..e2d1e08 100644
Binary files a/java/server/src/test/dataset/output/example-transposed.obl and b/java/server/src/test/dataset/output/example-transposed.obl differ
diff --git a/java/server/src/test/dataset/output/example-transposed.offsets b/java/server/src/test/dataset/output/example-transposed.offsets
index de6c354..c0ad3d0 100644
--- a/java/server/src/test/dataset/output/example-transposed.offsets
+++ b/java/server/src/test/dataset/output/example-transposed.offsets
@@ -1 +1,2 @@
-¡BŽ(áa‚†Œ8aƊ8¤
\ No newline at end of file
+ŽqAqACEQСB…
+€
\ No newline at end of file
diff --git a/java/server/src/test/dataset/output/example-transposed.properties b/java/server/src/test/dataset/output/example-transposed.properties
index 978774f..b86a465 100644
--- a/java/server/src/test/dataset/output/example-transposed.properties
+++ b/java/server/src/test/dataset/output/example-transposed.properties
@@ -1,35 +1,35 @@
#BVGraph properties
-#Thu Jul 11 10:00:30 GMT 2019
-bitsforreferences=27
-avgbitsforintervals=0.5
+#Mon Jul 29 09:58:01 GMT 2019
+bitsforreferences=23
+avgbitsforintervals=0.762
graphclass=it.unimi.dsi.big.webgraph.BVGraph
-avgdist=0.45
-successoravggap=4.955
-residualexpstats=4,3,5,2
-arcs=22
+avgdist=0.19
+successoravggap=5.891
+residualexpstats=8,5,3,0,2,1
+arcs=23
minintervallength=4
-bitsforoutdegrees=58
-residualavgloggap=2.1579982668876947
-avgbitsforoutdegrees=2.9
-bitsforresiduals=60
-successoravgloggap=2.3575375071412092
+bitsforoutdegrees=61
+residualavgloggap=2.1035487523752026
+avgbitsforoutdegrees=2.905
+bitsforresiduals=86
+successoravgloggap=2.08748530092112
maxrefcount=3
-successorexpstats=4,4,11,3
-residualarcs=14
-avgbitsforresiduals=3
-avgbitsforblocks=1.35
+successorexpstats=8,7,5,1,1,1
+residualarcs=19
+avgbitsforresiduals=4.095
+avgbitsforblocks=0.19
windowsize=7
-residualavggap=4.429
-copiedarcs=8
-avgbitsforreferences=1.35
+residualavggap=6.921
+copiedarcs=4
+avgbitsforreferences=1.095
version=0
-compratio=1.541
-bitsperlink=8.364
+compratio=1.515
+bitsperlink=8.348
compressionflags=
-nodes=20
-avgref=0.45
+nodes=21
+avgref=0.19
zetak=3
-bitsforintervals=10
+bitsforintervals=16
intervalisedarcs=0
-bitspernode=9.2
-bitsforblocks=27
+bitspernode=9.143
+bitsforblocks=4
diff --git a/java/server/src/test/dataset/output/example.graph b/java/server/src/test/dataset/output/example.graph
index 85fa99e..a8febfc 100644
--- a/java/server/src/test/dataset/output/example.graph
+++ b/java/server/src/test/dataset/output/example.graph
@@ -1 +1 @@
-]¾ãö?å~ÿÚ“ù¿bûZÃz
\ No newline at end of file
+}Êîû‹Ò{"îývõDiJÏoXDöeÐ
\ No newline at end of file
diff --git a/java/server/src/test/dataset/output/example.mph b/java/server/src/test/dataset/output/example.mph
index ca3a175..aa5a346 100644
Binary files a/java/server/src/test/dataset/output/example.mph and b/java/server/src/test/dataset/output/example.mph differ
diff --git a/java/server/src/test/dataset/output/example.nodeToSwhMap.csv b/java/server/src/test/dataset/output/example.node2pid.csv
similarity index 95%
rename from java/server/src/test/dataset/output/example.nodeToSwhMap.csv
rename to java/server/src/test/dataset/output/example.node2pid.csv
index 387392b..734a2bd 100644
--- a/java/server/src/test/dataset/output/example.nodeToSwhMap.csv
+++ b/java/server/src/test/dataset/output/example.node2pid.csv
@@ -1,20 +1,21 @@
-swh:1:rel:0000000000000000000000000000000000000019
-swh:1:rev:0000000000000000000000000000000000000018
swh:1:dir:0000000000000000000000000000000000000017
-swh:1:rev:0000000000000000000000000000000000000013
swh:1:cnt:0000000000000000000000000000000000000014
swh:1:dir:0000000000000000000000000000000000000016
-swh:1:rev:0000000000000000000000000000000000000009
-swh:1:dir:0000000000000000000000000000000000000012
swh:1:cnt:0000000000000000000000000000000000000015
-swh:1:dir:0000000000000000000000000000000000000008
+swh:1:rev:0000000000000000000000000000000000000009
swh:1:rev:0000000000000000000000000000000000000003
-swh:1:cnt:0000000000000000000000000000000000000011
+swh:1:dir:0000000000000000000000000000000000000008
+swh:1:dir:0000000000000000000000000000000000000002
swh:1:cnt:0000000000000000000000000000000000000001
-swh:1:cnt:0000000000000000000000000000000000000007
swh:1:dir:0000000000000000000000000000000000000006
-swh:1:dir:0000000000000000000000000000000000000002
-swh:1:cnt:0000000000000000000000000000000000000004
+swh:1:cnt:0000000000000000000000000000000000000007
swh:1:cnt:0000000000000000000000000000000000000005
-swh:1:rel:0000000000000000000000000000000000000010
+swh:1:cnt:0000000000000000000000000000000000000004
+swh:1:ori:0000000000000000000000000000000000000021
swh:1:snp:0000000000000000000000000000000000000020
+swh:1:rel:0000000000000000000000000000000000000010
+swh:1:cnt:0000000000000000000000000000000000000011
+swh:1:rev:0000000000000000000000000000000000000013
+swh:1:dir:0000000000000000000000000000000000000012
+swh:1:rev:0000000000000000000000000000000000000018
+swh:1:rel:0000000000000000000000000000000000000019
diff --git a/java/server/src/test/dataset/output/example.node2type.map b/java/server/src/test/dataset/output/example.node2type.map
new file mode 100644
index 0000000..f101e88
Binary files /dev/null and b/java/server/src/test/dataset/output/example.node2type.map differ
diff --git a/java/server/src/test/dataset/output/example.obl b/java/server/src/test/dataset/output/example.obl
index d639183..b957900 100644
Binary files a/java/server/src/test/dataset/output/example.obl and b/java/server/src/test/dataset/output/example.obl differ
diff --git a/java/server/src/test/dataset/output/example.offsets b/java/server/src/test/dataset/output/example.offsets
index 9808515..11a379f 100644
--- a/java/server/src/test/dataset/output/example.offsets
+++ b/java/server/src/test/dataset/output/example.offsets
@@ -1 +1 @@
-Š4j4r I á€
\ No newline at end of file
+BÑA!HjHPTb
diff --git a/java/server/src/test/dataset/output/example.order b/java/server/src/test/dataset/output/example.order
index b6d8ec5..f0b5624 100644
Binary files a/java/server/src/test/dataset/output/example.order and b/java/server/src/test/dataset/output/example.order differ
diff --git a/java/server/src/test/dataset/output/example.swhToNodeMap.csv b/java/server/src/test/dataset/output/example.pid2node.csv
similarity index 95%
rename from java/server/src/test/dataset/output/example.swhToNodeMap.csv
rename to java/server/src/test/dataset/output/example.pid2node.csv
index 5b36cff..85bec69 100644
--- a/java/server/src/test/dataset/output/example.swhToNodeMap.csv
+++ b/java/server/src/test/dataset/output/example.pid2node.csv
@@ -1,20 +1,21 @@
-swh:1:cnt:0000000000000000000000000000000000000001 00000000000000000012
-swh:1:cnt:0000000000000000000000000000000000000004 00000000000000000016
-swh:1:cnt:0000000000000000000000000000000000000005 00000000000000000017
-swh:1:cnt:0000000000000000000000000000000000000007 00000000000000000013
-swh:1:cnt:0000000000000000000000000000000000000011 00000000000000000011
-swh:1:cnt:0000000000000000000000000000000000000014 00000000000000000004
-swh:1:cnt:0000000000000000000000000000000000000015 00000000000000000008
-swh:1:dir:0000000000000000000000000000000000000002 00000000000000000015
-swh:1:dir:0000000000000000000000000000000000000006 00000000000000000014
-swh:1:dir:0000000000000000000000000000000000000008 00000000000000000009
-swh:1:dir:0000000000000000000000000000000000000012 00000000000000000007
-swh:1:dir:0000000000000000000000000000000000000016 00000000000000000005
-swh:1:dir:0000000000000000000000000000000000000017 00000000000000000002
-swh:1:rel:0000000000000000000000000000000000000010 00000000000000000018
-swh:1:rel:0000000000000000000000000000000000000019 00000000000000000000
-swh:1:rev:0000000000000000000000000000000000000003 00000000000000000010
-swh:1:rev:0000000000000000000000000000000000000009 00000000000000000006
-swh:1:rev:0000000000000000000000000000000000000013 00000000000000000003
-swh:1:rev:0000000000000000000000000000000000000018 00000000000000000001
-swh:1:snp:0000000000000000000000000000000000000020 00000000000000000019
+swh:1:cnt:0000000000000000000000000000000000000001 00000000000000000008
+swh:1:cnt:0000000000000000000000000000000000000004 00000000000000000012
+swh:1:cnt:0000000000000000000000000000000000000005 00000000000000000011
+swh:1:cnt:0000000000000000000000000000000000000007 00000000000000000010
+swh:1:cnt:0000000000000000000000000000000000000011 00000000000000000016
+swh:1:cnt:0000000000000000000000000000000000000014 00000000000000000001
+swh:1:cnt:0000000000000000000000000000000000000015 00000000000000000003
+swh:1:dir:0000000000000000000000000000000000000002 00000000000000000007
+swh:1:dir:0000000000000000000000000000000000000006 00000000000000000009
+swh:1:dir:0000000000000000000000000000000000000008 00000000000000000006
+swh:1:dir:0000000000000000000000000000000000000012 00000000000000000018
+swh:1:dir:0000000000000000000000000000000000000016 00000000000000000002
+swh:1:dir:0000000000000000000000000000000000000017 00000000000000000000
+swh:1:ori:0000000000000000000000000000000000000021 00000000000000000013
+swh:1:rel:0000000000000000000000000000000000000010 00000000000000000015
+swh:1:rel:0000000000000000000000000000000000000019 00000000000000000020
+swh:1:rev:0000000000000000000000000000000000000003 00000000000000000005
+swh:1:rev:0000000000000000000000000000000000000009 00000000000000000004
+swh:1:rev:0000000000000000000000000000000000000013 00000000000000000017
+swh:1:rev:0000000000000000000000000000000000000018 00000000000000000019
+swh:1:snp:0000000000000000000000000000000000000020 00000000000000000014
diff --git a/java/server/src/test/dataset/output/example.properties b/java/server/src/test/dataset/output/example.properties
index 1dd6c48..02dd23e 100644
--- a/java/server/src/test/dataset/output/example.properties
+++ b/java/server/src/test/dataset/output/example.properties
@@ -1,35 +1,35 @@
#BVGraph properties
-#Thu Jul 11 10:00:28 GMT 2019
-bitsforreferences=14
-avgbitsforintervals=0.65
+#Mon Jul 29 09:57:59 GMT 2019
+bitsforreferences=17
+avgbitsforintervals=0.619
graphclass=it.unimi.dsi.big.webgraph.BVGraph
-avgdist=0.05
-successoravggap=5.841
-residualexpstats=8,3,8,1,1
-arcs=22
+avgdist=0.143
+successoravggap=10.196
+residualexpstats=6,6,3,2,3,1
+arcs=23
minintervallength=4
-bitsforoutdegrees=48
-residualavgloggap=2.061149930723404
-avgbitsforoutdegrees=2.4
-bitsforresiduals=84
-successoravgloggap=2.2973961172309734
+bitsforoutdegrees=51
+residualavgloggap=2.4608192114691003
+avgbitsforoutdegrees=2.429
+bitsforresiduals=101
+successoravgloggap=2.727961930295593
maxrefcount=3
-successorexpstats=7,3,8,2,2
+successorexpstats=6,5,3,3,5,1
residualarcs=21
-avgbitsforresiduals=4.2
-avgbitsforblocks=0.05
+avgbitsforresiduals=4.81
+avgbitsforblocks=0.333
windowsize=7
-residualavggap=4.500
-copiedarcs=1
-avgbitsforreferences=0.7
+residualavggap=8.500
+copiedarcs=2
+avgbitsforreferences=0.81
version=0
-compratio=1.34
-bitsperlink=7.273
+compratio=1.515
+bitsperlink=8.348
compressionflags=
-nodes=20
-avgref=0.05
+nodes=21
+avgref=0.143
zetak=3
bitsforintervals=13
intervalisedarcs=0
-bitspernode=8
-bitsforblocks=1
+bitspernode=9.143
+bitsforblocks=7
diff --git a/java/server/src/test/java/org/softwareheritage/graph/LeavesTest.java b/java/server/src/test/java/org/softwareheritage/graph/LeavesTest.java
index 53f68f9..46e8797 100644
--- a/java/server/src/test/java/org/softwareheritage/graph/LeavesTest.java
+++ b/java/server/src/test/java/org/softwareheritage/graph/LeavesTest.java
@@ -1,101 +1,101 @@
package org.softwareheritage.graph;
import java.util.ArrayList;
import org.junit.Test;
import org.softwareheritage.graph.Endpoint;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.GraphTest;
import org.softwareheritage.graph.SwhId;
public class LeavesTest extends GraphTest {
@Test
public void forwardFromSnp() {
Graph graph = getGraph();
SwhId src = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> expectedLeaves = new ArrayList<>();
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000004"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000005"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedLeaves, endpoint.leaves(src));
}
@Test
public void forwardFromRel() {
Graph graph = getGraph();
SwhId src = new SwhId("swh:1:rel:0000000000000000000000000000000000000019");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> expectedLeaves = new ArrayList<>();
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000015"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000014"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000004"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000005"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000011"));
GraphTest.assertEqualsAnyOrder(expectedLeaves, endpoint.leaves(src));
}
@Test
public void backwardFromLeaf() {
Graph graph = getGraph();
Endpoint endpoint = new Endpoint(graph, "backward", "*");
SwhId src1 = new SwhId("swh:1:cnt:0000000000000000000000000000000000000015");
ArrayList<SwhId> expectedLeaves1 = new ArrayList<>();
expectedLeaves1.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000019"));
GraphTest.assertEqualsAnyOrder(expectedLeaves1, endpoint.leaves(src1));
SwhId src2 = new SwhId("swh:1:cnt:0000000000000000000000000000000000000004");
ArrayList<SwhId> expectedLeaves2 = new ArrayList<>();
- expectedLeaves2.add(new SwhId("swh:1:snp:0000000000000000000000000000000000000020"));
+ expectedLeaves2.add(new SwhId("swh:1:ori:0000000000000000000000000000000000000021"));
expectedLeaves2.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000019"));
GraphTest.assertEqualsAnyOrder(expectedLeaves2, endpoint.leaves(src2));
}
@Test
public void forwardRevToRevOnly() {
Graph graph = getGraph();
SwhId src = new SwhId("swh:1:rev:0000000000000000000000000000000000000018");
Endpoint endpoint = new Endpoint(graph, "forward", "rev:rev");
ArrayList<SwhId> expectedLeaves = new ArrayList<>();
expectedLeaves.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000003"));
GraphTest.assertEqualsAnyOrder(expectedLeaves, endpoint.leaves(src));
}
@Test
public void forwardDirToAll() {
Graph graph = getGraph();
SwhId src = new SwhId("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint = new Endpoint(graph, "forward", "dir:*");
ArrayList<SwhId> expectedLeaves = new ArrayList<>();
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000004"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000005"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedLeaves.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedLeaves, endpoint.leaves(src));
}
@Test
public void backwardCntToDirDirToDir() {
Graph graph = getGraph();
SwhId src = new SwhId("swh:1:cnt:0000000000000000000000000000000000000005");
Endpoint endpoint = new Endpoint(graph, "backward", "cnt:dir,dir:dir");
ArrayList<SwhId> expectedLeaves = new ArrayList<>();
expectedLeaves.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000012"));
GraphTest.assertEqualsAnyOrder(expectedLeaves, endpoint.leaves(src));
}
}
diff --git a/java/server/src/test/java/org/softwareheritage/graph/NeighborsTest.java b/java/server/src/test/java/org/softwareheritage/graph/NeighborsTest.java
index 9fec292..25b524f 100644
--- a/java/server/src/test/java/org/softwareheritage/graph/NeighborsTest.java
+++ b/java/server/src/test/java/org/softwareheritage/graph/NeighborsTest.java
@@ -1,121 +1,127 @@
package org.softwareheritage.graph;
import java.util.ArrayList;
import org.junit.Test;
import org.softwareheritage.graph.Endpoint;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.GraphTest;
import org.softwareheritage.graph.SwhId;
public class NeighborsTest extends GraphTest {
@Test
public void zeroNeighbor() {
Graph graph = getGraph();
ArrayList<SwhId> expectedNodes = new ArrayList<>();
- SwhId src1 = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
+ SwhId src1 = new SwhId("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
GraphTest.assertEqualsAnyOrder(expectedNodes, endpoint1.neighbors(src1));
SwhId src2 = new SwhId("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
GraphTest.assertEqualsAnyOrder(expectedNodes, endpoint2.neighbors(src2));
SwhId src3 = new SwhId("swh:1:cnt:0000000000000000000000000000000000000015");
Endpoint endpoint3 = new Endpoint(graph, "forward", "*");
GraphTest.assertEqualsAnyOrder(expectedNodes, endpoint3.neighbors(src3));
SwhId src4 = new SwhId("swh:1:rel:0000000000000000000000000000000000000019");
Endpoint endpoint4 = new Endpoint(graph, "backward", "*");
GraphTest.assertEqualsAnyOrder(expectedNodes, endpoint4.neighbors(src4));
SwhId src5 = new SwhId("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint5 = new Endpoint(graph, "forward", "snp:*,rev:*,rel:*");
GraphTest.assertEqualsAnyOrder(expectedNodes, endpoint5.neighbors(src5));
}
@Test
public void oneNeighbor() {
Graph graph = getGraph();
SwhId src1 = new SwhId("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> expectedNodes1 = new ArrayList<>();
expectedNodes1.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000002"));
GraphTest.assertEqualsAnyOrder(expectedNodes1, endpoint1.neighbors(src1));
SwhId src2 = new SwhId("swh:1:dir:0000000000000000000000000000000000000017");
Endpoint endpoint2 = new Endpoint(graph, "forward", "dir:cnt");
ArrayList<SwhId> expectedNodes2 = new ArrayList<>();
expectedNodes2.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000014"));
GraphTest.assertEqualsAnyOrder(expectedNodes2, endpoint2.neighbors(src2));
SwhId src3 = new SwhId("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint3 = new Endpoint(graph, "backward", "*");
ArrayList<SwhId> expectedNodes3 = new ArrayList<>();
expectedNodes3.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000013"));
GraphTest.assertEqualsAnyOrder(expectedNodes3, endpoint3.neighbors(src3));
SwhId src4 = new SwhId("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint4 = new Endpoint(graph, "backward", "rev:rev");
ArrayList<SwhId> expectedNodes4 = new ArrayList<>();
expectedNodes4.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000013"));
GraphTest.assertEqualsAnyOrder(expectedNodes4, endpoint4.neighbors(src4));
+
+ SwhId src5 = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
+ Endpoint endpoint5 = new Endpoint(graph, "backward", "*");
+ ArrayList<SwhId> expectedNodes5 = new ArrayList<>();
+ expectedNodes5.add(new SwhId("swh:1:ori:0000000000000000000000000000000000000021"));
+ GraphTest.assertEqualsAnyOrder(expectedNodes5, endpoint5.neighbors(src5));
}
@Test
public void twoNeighbors() {
Graph graph = getGraph();
SwhId src1 = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> expectedNodes1 = new ArrayList<>();
expectedNodes1.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000010"));
expectedNodes1.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000009"));
GraphTest.assertEqualsAnyOrder(expectedNodes1, endpoint1.neighbors(src1));
SwhId src2 = new SwhId("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint2 = new Endpoint(graph, "forward", "dir:cnt");
ArrayList<SwhId> expectedNodes2 = new ArrayList<>();
expectedNodes2.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedNodes2.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedNodes2, endpoint2.neighbors(src2));
SwhId src3 = new SwhId("swh:1:cnt:0000000000000000000000000000000000000001");
Endpoint endpoint3 = new Endpoint(graph, "backward", "*");
ArrayList<SwhId> expectedNodes3 = new ArrayList<>();
expectedNodes3.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000008"));
expectedNodes3.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000002"));
GraphTest.assertEqualsAnyOrder(expectedNodes3, endpoint3.neighbors(src3));
SwhId src4 = new SwhId("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint4 = new Endpoint(graph, "backward", "rev:snp,rev:rel");
ArrayList<SwhId> expectedNodes4 = new ArrayList<>();
expectedNodes4.add(new SwhId("swh:1:snp:0000000000000000000000000000000000000020"));
expectedNodes4.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000010"));
GraphTest.assertEqualsAnyOrder(expectedNodes4, endpoint4.neighbors(src4));
}
@Test
public void threeNeighbors() {
Graph graph = getGraph();
SwhId src1 = new SwhId("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> expectedNodes1 = new ArrayList<>();
expectedNodes1.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000006"));
expectedNodes1.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedNodes1.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedNodes1, endpoint1.neighbors(src1));
SwhId src2 = new SwhId("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
ArrayList<SwhId> expectedNodes2 = new ArrayList<>();
expectedNodes2.add(new SwhId("swh:1:snp:0000000000000000000000000000000000000020"));
expectedNodes2.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000010"));
expectedNodes2.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000013"));
GraphTest.assertEqualsAnyOrder(expectedNodes2, endpoint2.neighbors(src2));
}
}
diff --git a/java/server/src/test/java/org/softwareheritage/graph/VisitTest.java b/java/server/src/test/java/org/softwareheritage/graph/VisitTest.java
index 2f9a731..dbc2ff3 100644
--- a/java/server/src/test/java/org/softwareheritage/graph/VisitTest.java
+++ b/java/server/src/test/java/org/softwareheritage/graph/VisitTest.java
@@ -1,520 +1,533 @@
package org.softwareheritage.graph;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import org.junit.Test;
import org.softwareheritage.graph.Endpoint;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.GraphTest;
import org.softwareheritage.graph.SwhId;
import org.softwareheritage.graph.SwhPath;
public class VisitTest extends GraphTest {
private void assertSameNodesFromPaths(ArrayList<SwhPath> paths, ArrayList<SwhId> nodes) {
Set<SwhId> expectedNodes = new HashSet<SwhId>();
for (SwhPath path : paths) {
for (SwhId node : path.getPath()) {
expectedNodes.add(node);
}
}
GraphTest.assertEqualsAnyOrder(expectedNodes, nodes);
}
@Test
public void forwardFromRoot() {
Graph graph = getGraph();
- SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
+ SwhId swhId = new SwhId("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000005"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000005"
));
expectedPaths.add(
new SwhPath(
+ "swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardFromMiddle() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000005"
));
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:cnt:0000000000000000000000000000000000000011"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardFromLeaf() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000004"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void backwardFromRoot() {
Graph graph = getGraph();
- SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
+ SwhId swhId = new SwhId("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint = new Endpoint(graph, "backward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020"
+ "swh:1:ori:0000000000000000000000000000000000000021"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void backwardFromMiddle() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint = new Endpoint(graph, "backward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
"swh:1:rel:0000000000000000000000000000000000000019"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void backwardFromLeaf() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint = new Endpoint(graph, "backward", "*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
"swh:1:rel:0000000000000000000000000000000000000019"
));
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
"swh:1:rel:0000000000000000000000000000000000000019"
));
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:snp:0000000000000000000000000000000000000020"
+ "swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:ori:0000000000000000000000000000000000000021"
));
expectedPaths.add(
new SwhPath(
"swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rel:0000000000000000000000000000000000000010",
- "swh:1:snp:0000000000000000000000000000000000000020"
+ "swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:ori:0000000000000000000000000000000000000021"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardSnpToRev() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint = new Endpoint(graph, "forward", "snp:rev");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardRelToRevRevToRev() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:rel:0000000000000000000000000000000000000010");
Endpoint endpoint = new Endpoint(graph, "forward", "rel:rev,rev:rev");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardRevToAllDirToAll() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:rev:0000000000000000000000000000000000000013");
Endpoint endpoint = new Endpoint(graph, "forward", "rev:*,dir:*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000005"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000005"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:cnt:0000000000000000000000000000000000000004"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000007"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:cnt:0000000000000000000000000000000000000011"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:cnt:0000000000000000000000000000000000000001"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardSnpToAllRevToAll() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint = new Endpoint(graph, "forward", "snp:*,rev:*");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002"
));
expectedPaths.add(
new SwhPath(
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008"
));
expectedPaths.add(
new SwhPath(
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardNoEdges() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint = new Endpoint(graph, "forward", "");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:snp:0000000000000000000000000000000000000020"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void backwardRevToRevRevToRel() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint = new Endpoint(graph, "backward", "rev:rev,rev:rel");
ArrayList<SwhPath> paths = endpoint.visitPaths(swhId);
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
"swh:1:rel:0000000000000000000000000000000000000019"
));
expectedPaths.add(
new SwhPath(
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rel:0000000000000000000000000000000000000010"
));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
}
@Test
public void forwardFromRootNodesOnly() {
Graph graph = getGraph();
- SwhId swhId = new SwhId("swh:1:snp:0000000000000000000000000000000000000020");
+ SwhId swhId = new SwhId("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhId> expectedNodes = new ArrayList<SwhId>();
+ expectedNodes.add(new SwhId("swh:1:ori:0000000000000000000000000000000000000021"));
expectedNodes.add(new SwhId("swh:1:snp:0000000000000000000000000000000000000020"));
expectedNodes.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000010"));
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000009"));
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000003"));
expectedNodes.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000002"));
expectedNodes.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000001"));
expectedNodes.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000008"));
expectedNodes.add(new SwhId("swh:1:dir:0000000000000000000000000000000000000006"));
expectedNodes.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000004"));
expectedNodes.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000005"));
expectedNodes.add(new SwhId("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedNodes, nodes);
}
@Test
public void backwardRevToAllNodesOnly() {
Graph graph = getGraph();
SwhId swhId = new SwhId("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint = new Endpoint(graph, "backward", "rev:*");
ArrayList<SwhId> nodes = endpoint.visitNodes(swhId);
ArrayList<SwhId> expectedNodes = new ArrayList<SwhId>();
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000003"));
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000009"));
expectedNodes.add(new SwhId("swh:1:snp:0000000000000000000000000000000000000020"));
expectedNodes.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000010"));
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000013"));
expectedNodes.add(new SwhId("swh:1:rev:0000000000000000000000000000000000000018"));
expectedNodes.add(new SwhId("swh:1:rel:0000000000000000000000000000000000000019"));
GraphTest.assertEqualsAnyOrder(expectedNodes, nodes);
}
}

File Metadata

Mime Type
application/octet-stream
Expires
Sat, Apr 27, 5:48 PM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3148566

Event Timeline