use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method assertContains.
private static void assertContains(List<Edge> edges, Object source, String label, Object target, Object... keyValues) {
Map<String, Object> properties = Utils.asMap(keyValues);
Edge edge = new Edge(label);
edge.sourceId(source);
edge.targetId(target);
for (String key : properties.keySet()) {
edge.property(key, properties.get(key));
}
Assert.assertTrue(Utils.contains(edges, edge));
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testAddEdgePropertyValueListWithSameValue.
@Test
public void testAddEdgePropertyValueListWithSameValue() {
schema().propertyKey("time").asDate().valueList().ifNotExist().create();
schema().edgeLabel("created").properties("time").nullableKeys("time").append();
Object peterId = getVertexId("person", "name", "peter");
Object lopId = getVertexId("software", "name", "lop");
Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24", "time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of(Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2012-10-10");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of(Utils.formatDate("2012-10-10"), Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testAddEdgePropertyValueSet.
@Test
public void testAddEdgePropertyValueSet() {
schema().propertyKey("time").asDate().valueSet().ifNotExist().create();
schema().edgeLabel("created").properties("time").nullableKeys("time").append();
Object peterId = getVertexId("person", "name", "peter");
Object lopId = getVertexId("software", "name", "lop");
Edge created = graph().addEdge(peterId, "created", lopId, "date", "2017-03-24", "time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of(Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, created.properties());
created.property("time", "2014-02-14");
props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "time", ImmutableList.of(Utils.formatDate("2012-10-10"), Utils.formatDate("2014-02-14")));
Assert.assertEquals(props, created.properties());
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeApiTest method testBatchCreateWithInvalidVertexLabelAndCheck.
@Test
public void testBatchCreateWithInvalidVertexLabelAndCheck() {
List<Edge> edges = new ArrayList<>(2);
Edge edge1 = new Edge("created");
edge1.sourceId("person:peter");
edge1.targetId("software:lop");
edge1.property("date", "2017-03-24");
edge1.property("city", "Hongkong");
edges.add(edge1);
Edge edge2 = new Edge("knows");
edge2.sourceLabel("undefined");
edge2.targetLabel("undefined");
edge2.sourceId("person:peter");
edge2.targetId("person:marko");
edge2.property("date", "2017-03-24");
edges.add(edge2);
Utils.assertResponseError(400, () -> {
edgeAPI.create(edges, true);
});
}
use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.
the class EdgeApiTest method testCreateWithUndefinedLabel.
@Test
public void testCreateWithUndefinedLabel() {
Object outVId = getVertexId("person", "name", "peter");
Object inVId = getVertexId("software", "name", "lop");
Edge edge = new Edge("undefined");
edge.sourceLabel("person");
edge.targetLabel("software");
edge.sourceId(outVId);
edge.targetId(inVId);
edge.property("date", "2017-03-24");
edge.property("city", "Hongkong");
Utils.assertResponseError(400, () -> {
edgeAPI.create(edge);
});
}
Aggregations