use of com.baidu.hugegraph.structure.graph.UpdateStrategy in project incubator-hugegraph-toolchain by apache.
the class BatchElementRequestTest method testVertexRequestBuildOK.
@Test
public void testVertexRequestBuildOK() {
List<Vertex> vertices = ImmutableList.of(createVertex());
Map<String, UpdateStrategy> strategies = ImmutableMap.of("set", INTERSECTION);
BatchVertexRequest req;
req = new BatchVertexRequest.Builder().vertices(vertices).updatingStrategies(strategies).createIfNotExist(true).build();
Assert.assertNotNull(req);
Object list = Whitebox.getInternalState(req, "vertices");
Assert.assertEquals(vertices, list);
Object map = Whitebox.getInternalState(req, "updateStrategies");
Assert.assertEquals(strategies, map);
Object created = Whitebox.getInternalState(req, "createIfNotExist");
Assert.assertEquals(true, created);
}
use of com.baidu.hugegraph.structure.graph.UpdateStrategy in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method testVertexBatchUpdateStrategyOverride.
@Test
public void testVertexBatchUpdateStrategyOverride() {
BatchVertexRequest req = batchVertexRequest("price", -1, 1, UpdateStrategy.OVERRIDE);
assertBatchResponse(vertexAPI.update(req), "price", 1);
// Construct a specialized test case
graph().addVertices(this.createNVertexBatch("object", -1, 2));
List<String> list = ImmutableList.of("newStr1", "newStr2");
Vertex v1 = new Vertex("object");
v1.property("name", "tom");
v1.property("price", 1);
v1.property("list", list);
Vertex v2 = new Vertex("object");
v2.property("name", "tom");
Map<String, UpdateStrategy> strategies;
strategies = ImmutableMap.of("price", UpdateStrategy.OVERRIDE, "list", UpdateStrategy.OVERRIDE);
req = BatchVertexRequest.createBuilder().vertices(ImmutableList.of(v1, v2)).updatingStrategies(strategies).createIfNotExist(true).build();
List<Vertex> vertices = vertexAPI.update(req);
Assert.assertEquals(1, vertices.size());
Map<String, Object> expectProperties = ImmutableMap.of("name", "tom", "price", 1, "list", list);
Assert.assertEquals(vertices.get(0).properties(), expectProperties);
}
use of com.baidu.hugegraph.structure.graph.UpdateStrategy in project incubator-hugegraph-toolchain by apache.
the class BatchElementRequestTest method testEdgeRequestBuildOK.
@Test
public void testEdgeRequestBuildOK() {
List<Edge> edges = ImmutableList.of(createEdge());
Map<String, UpdateStrategy> strategies = ImmutableMap.of("set", INTERSECTION);
BatchEdgeRequest req;
req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
Assert.assertNotNull(req);
Object list = Whitebox.getInternalState(req, "edges");
Assert.assertEquals(edges, list);
Object map = Whitebox.getInternalState(req, "updateStrategies");
Assert.assertEquals(strategies, map);
Object checked = Whitebox.getInternalState(req, "checkVertex");
Assert.assertEquals(false, checked);
Object created = Whitebox.getInternalState(req, "createIfNotExist");
Assert.assertEquals(true, created);
}
use of com.baidu.hugegraph.structure.graph.UpdateStrategy in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method batchEdgeRequest.
private BatchEdgeRequest batchEdgeRequest(String key, Object oldData, Object newData, UpdateStrategy strategy) {
// Init old vertices & edges
graph().addVertices(this.createNVertexBatch("object", oldData, BATCH_SIZE * 2));
graph().addEdges(this.createNEdgesBatch("object", "updates", oldData, BATCH_SIZE));
List<Edge> edges = this.createNEdgesBatch("object", "updates", newData, BATCH_SIZE);
Map<String, UpdateStrategy> strategies = ImmutableMap.of(key, strategy);
BatchEdgeRequest req;
req = new BatchEdgeRequest.Builder().edges(edges).updatingStrategies(strategies).checkVertex(false).createIfNotExist(true).build();
return req;
}
use of com.baidu.hugegraph.structure.graph.UpdateStrategy in project incubator-hugegraph-toolchain by apache.
the class BatchUpdateElementApiTest method batchVertexRequest.
private BatchVertexRequest batchVertexRequest(String key, Object oldData, Object newData, UpdateStrategy strategy) {
// Init old & new vertices
graph().addVertices(this.createNVertexBatch("object", oldData, BATCH_SIZE));
List<Vertex> vertices = this.createNVertexBatch("object", newData, BATCH_SIZE);
Map<String, UpdateStrategy> strategies = ImmutableMap.of(key, strategy);
BatchVertexRequest req;
req = new BatchVertexRequest.Builder().vertices(vertices).updatingStrategies(strategies).createIfNotExist(true).build();
return req;
}
Aggregations