use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testEliminateVertexLabelWithUserData.
@Test
public void testEliminateVertexLabelWithUserData() {
SchemaManager schema = schema();
VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").userdata("icon", "picture1").create();
Assert.assertEquals(3, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
Assert.assertEquals("picture1", player.userdata().get("icon"));
String time = (String) player.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
player = schema.vertexLabel("player").userdata("icon", "").eliminate();
Assert.assertEquals(2, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
time = (String) player.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
use of com.baidu.hugegraph.driver.SchemaManager 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.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testRemoveVertexLabelSync.
@Test
public void testRemoveVertexLabelSync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name").create();
// Remove vertex label sync
schema.removeVertexLabel("player");
schema.vertexLabel("player").properties("name").create();
// Remove vertex label sync with timeout
schema.removeVertexLabel("player", 10);
}
use of com.baidu.hugegraph.driver.SchemaManager 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.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class VertexLabelTest method testRemoveVertexLabelASync.
@Test
public void testRemoveVertexLabelASync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name").create();
// Remove vertex label async and wait
long taskId = schema.removeVertexLabelAsync("player");
Task task = task().waitUntilTaskCompleted(taskId, 10);
Assert.assertTrue(task.completed());
}
Aggregations