use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testGetEdgesByVertexIdWithLimit2.
@Test
public void testGetEdgesByVertexIdWithLimit2() {
BaseClientTest.initEdge();
Object markoId = getVertexId("person", "name", "marko");
List<Edge> edges = graph().getEdges(markoId, 2);
Assert.assertEquals(2, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(markoId, edge.sourceId());
}
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testName.
@Test
public void testName() {
BaseClientTest.initEdge();
Object markoId = getVertexId("person", "name", "marko");
List<Edge> edges = graph().getEdges(markoId, Direction.OUT, "knows");
Assert.assertEquals(2, edges.size());
Edge edge1 = edges.get(0);
Edge edge2 = edges.get(1);
Date date1 = DateUtil.parse((String) edge1.property("date"));
Date date2 = DateUtil.parse((String) edge2.property("date"));
String name1 = edge1.name();
String name2 = edge2.name();
if (date1.before(date2)) {
Assert.assertTrue(name1.compareTo(name2) < 0);
} else {
Assert.assertTrue(name1.compareTo(name2) >= 0);
}
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testGetEdgesByVertexIdDirectionWithLimit1.
@Test
public void testGetEdgesByVertexIdDirectionWithLimit1() {
BaseClientTest.initEdge();
Object joshId = getVertexId("person", "name", "josh");
List<Edge> edges = graph().getEdges(joshId, Direction.OUT, 1);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
// TODO: Whether need to add direction property in Edge?
Assert.assertEquals(joshId, edge.sourceId());
}
edges = graph().getEdges(joshId, Direction.IN, 1);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(joshId, edge.targetId());
}
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testAddEdgeWithMapProperties.
@Test
public void testAddEdgeWithMapProperties() {
Vertex peter = getVertex("person", "name", "peter");
Vertex lop = getVertex("software", "name", "lop");
Map<String, Object> properties = ImmutableMap.of("date", "2017-03-24", "city", "HongKong");
Edge created = graph().addEdge(peter, "created", lop, properties);
Map<String, Object> props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "city", "HongKong");
Assert.assertEquals(props, created.properties());
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testGetEdgesByVertexIdDirectionLabelWithLimit1.
@Test
public void testGetEdgesByVertexIdDirectionLabelWithLimit1() {
BaseClientTest.initEdge();
Object joshId = getVertexId("person", "name", "josh");
List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created", 1);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(joshId, edge.sourceId());
Assert.assertEquals("created", edge.label());
}
edges = graph().getEdges(joshId, Direction.IN, "knows", 1);
Assert.assertEquals(1, edges.size());
for (Edge edge : edges) {
Assert.assertEquals(joshId, edge.targetId());
Assert.assertEquals("knows", edge.label());
}
}
Aggregations