use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateExistedVertexLabel.
@Test
public void testCreateExistedVertexLabel() {
VertexLabel vertexLabel = new VertexLabel("name");
vertexLabelAPI.create(vertexLabel);
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(new VertexLabel("name"));
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithInvalidName.
@Test
public void testCreateWithInvalidName() {
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(new VertexLabel(""));
});
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(new VertexLabel(" "));
});
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(new VertexLabel(" "));
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithUndefinedPrimaryKey.
@Test
public void testCreateWithUndefinedPrimaryKey() {
VertexLabel vertexLabel = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("undefined").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.create(vertexLabel);
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testAddVertexLabelWithUserData.
@Test
public void testAddVertexLabelWithUserData() {
VertexLabel player = schema().vertexLabel("player").properties("name").userdata("super_vl", "person").build();
player = vertexLabelAPI.create(player);
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").build();
runner = vertexLabelAPI.create(runner);
// 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 VertexLabelApiTest method testAppendWithUndefinedNullabelKeys.
@Test
public void testAppendWithUndefinedNullabelKeys() {
VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age").build();
vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
Assert.assertEquals("person", vertexLabel1.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel1.idStrategy());
Set<String> props = ImmutableSet.of("name", "age");
Assert.assertEquals(props, vertexLabel1.properties());
VertexLabel vertexLabel2 = schema().vertexLabel("person").nullableKeys("undefined").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.append(vertexLabel2);
});
}
Aggregations