use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateWithNullValues.
@Test
public void testEdgeBatchUpdateWithNullValues() {
BatchEdgeRequest req = batchEdgeRequest("price", 1, null, UpdateStrategy.OVERRIDE);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 1);
}
use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategySum.
/* Edge Test */
@Test
public void testEdgeBatchUpdateStrategySum() {
BatchEdgeRequest req = batchEdgeRequest("price", -1, 1, UpdateStrategy.SUM);
List<Edge> edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 0);
req = batchEdgeRequest("price", 2, 3, UpdateStrategy.SUM);
edges = edgeAPI.update(req);
assertBatchResponse(edges, "price", 5);
}
use of com.baidu.hugegraph.structure.graph.BatchEdgeRequest in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testEdgeBatchUpdateStrategyOverride.
@Test
public void testEdgeBatchUpdateStrategyOverride() {
BatchEdgeRequest req = batchEdgeRequest("price", -1, 1, UpdateStrategy.OVERRIDE);
assertBatchResponse(edgeAPI.update(req), "price", 1);
// Construct a specialized test case
graph().addEdges(this.createNEdgesBatch("object", "updates", -1, 2));
List<String> list = ImmutableList.of("newStr1", "newStr2");
String vid = "1:a";
Edge e1 = new Edge("updates");
e1.sourceLabel("object");
e1.targetLabel("object");
e1.sourceId(vid);
e1.targetId(vid);
e1.property("name", "tom");
e1.property("price", 1);
e1.property("list", list);
Edge e2 = new Edge("updates");
e2.sourceLabel("object");
e2.targetLabel("object");
e2.sourceId(vid);
e2.targetId(vid);
e2.property("name", "tom");
Map<String, UpdateStrategy> strategies;
strategies = ImmutableMap.of("price", UpdateStrategy.OVERRIDE, "list", UpdateStrategy.OVERRIDE);
req = BatchEdgeRequest.createBuilder().edges(ImmutableList.of(e1, e2)).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
List<Edge> edges = edgeAPI.update(req);
Assert.assertEquals(1, edges.size());
Map<String, Object> expectProperties = ImmutableMap.of("name", "tom", "price", 1, "list", list);
Assert.assertEquals(edges.get(0).properties(), expectProperties);
}
Aggregations