use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testAddVertexLabelWithUserData.
@Test
public void testAddVertexLabelWithUserData() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").create();
Assert.assertEquals(2, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
String time = (String) player.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
VertexLabel runner = schema.vertexLabel("runner").properties("name").userdata("super_vl", "person").userdata("super_vl", "player").create();
// The same key user data will be overwritten
Assert.assertEquals(2, runner.userdata().size());
Assert.assertEquals("player", runner.userdata().get("super_vl"));
time = (String) runner.userdata().get("~create_time");
createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testListByNames.
@Test
public void testListByNames() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").create();
VertexLabel runner = schema.vertexLabel("runner").create();
List<VertexLabel> vertexLabels;
vertexLabels = schema.getVertexLabels(ImmutableList.of("player"));
Assert.assertEquals(1, vertexLabels.size());
assertContains(vertexLabels, player);
vertexLabels = schema.getVertexLabels(ImmutableList.of("runner"));
Assert.assertEquals(1, vertexLabels.size());
assertContains(vertexLabels, runner);
vertexLabels = schema.getVertexLabels(ImmutableList.of("player", "runner"));
Assert.assertEquals(2, vertexLabels.size());
assertContains(vertexLabels, player);
assertContains(vertexLabels, runner);
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeApiTest method testBatchCreateWithValidVertexAndNotCheck.
@Test
public void testBatchCreateWithValidVertexAndNotCheck() {
VertexLabel person = schema().getVertexLabel("person");
VertexLabel software = schema().getVertexLabel("software");
List<Vertex> persons = super.create100PersonBatch();
List<Vertex> softwares = super.create50SoftwareBatch();
vertexAPI.create(persons);
vertexAPI.create(softwares);
List<Edge> createds = super.create50CreatedBatch();
List<Edge> knows = super.create50KnowsBatch();
List<String> createdIds = edgeAPI.create(createds, false);
List<String> knowsIds = edgeAPI.create(knows, false);
Assert.assertEquals(50, createdIds.size());
Assert.assertEquals(50, knowsIds.size());
for (int i = 0; i < 50; i++) {
Edge created = edgeAPI.get(createdIds.get(i));
Assert.assertEquals("created", created.label());
Assert.assertEquals("person", created.sourceLabel());
Assert.assertEquals("software", created.targetLabel());
Assert.assertEquals(person.id() + ":Person-" + i, created.sourceId());
Assert.assertEquals(software.id() + ":Software-" + i, created.targetId());
String date = Utils.formatDate("2017-03-24");
Map<String, Object> props = ImmutableMap.of("date", date, "city", "Hongkong");
Assert.assertEquals(props, created.properties());
}
for (int i = 0; i < 50; i++) {
Edge know = edgeAPI.get(knowsIds.get(i));
Assert.assertEquals("knows", know.label());
Assert.assertEquals("person", know.sourceLabel());
Assert.assertEquals("person", know.targetLabel());
Assert.assertEquals(person.id() + ":Person-" + i, know.sourceId());
Assert.assertEquals(person.id() + ":Person-" + (i + 50), know.targetId());
String date = Utils.formatDate("2017-03-24");
Map<String, Object> props = ImmutableMap.of("date", date);
Assert.assertEquals(props, know.properties());
}
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class BaseClientTest method create50KnowsBatch.
protected List<Edge> create50KnowsBatch() {
VertexLabel person = schema().getVertexLabel("person");
List<Edge> edges = new ArrayList<>(50);
for (int i = 0; i < 50; i++) {
Edge edge = new Edge("knows");
edge.sourceLabel("person");
edge.targetLabel("person");
edge.sourceId(person.id() + ":Person-" + i);
edge.targetId(person.id() + ":Person-" + (i + 50));
edge.property("date", "2017-03-24");
edges.add(edge);
}
return edges;
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class JobApiTest method testRebuildVertexLabel.
@Test
public void testRebuildVertexLabel() {
VertexLabel person = schema().getVertexLabel("person");
long taskId = rebuildAPI.rebuild(person);
Task task = taskAPI.get(taskId);
Assert.assertNotNull(task);
Assert.assertEquals(taskId, task.id());
waitUntilTaskCompleted(taskId);
}
Aggregations