use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testEliminate.
@Test
public void testEliminate() {
VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
Assert.assertEquals("person", vertexLabel1.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel1.idStrategy());
Set<String> props = ImmutableSet.of("name", "age", "city");
Assert.assertEquals(props, vertexLabel1.properties());
VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("city").build();
Utils.assertResponseError(400, () -> {
vertexLabelAPI.eliminate(vertexLabel2);
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithEnableLabelIndexFalse.
@Test
public void testCreateWithEnableLabelIndexFalse() {
VertexLabel vertexLabel = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").enableLabelIndex(false).build();
vertexLabel = vertexLabelAPI.create(vertexLabel);
Assert.assertEquals("person", vertexLabel.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
Assert.assertEquals(false, vertexLabel.enableLabelIndex());
Set<String> props = ImmutableSet.of("name", "age", "city");
Assert.assertEquals(props, vertexLabel.properties());
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testCreateWithUndefinedPropertyKey.
@Test
public void testCreateWithUndefinedPropertyKey() {
VertexLabel vertexLabel = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "undefined").primaryKeys("name").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 testCreateWithUnmatchIdStrategyAndProperties.
@Test
public void testCreateWithUnmatchIdStrategyAndProperties() {
Utils.assertResponseError(400, () -> {
VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").useAutomaticId().primaryKeys("name").build();
vertexLabelAPI.create(vertexLabel);
});
Utils.assertResponseError(400, () -> {
VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").useCustomizeStringId().primaryKeys("name").build();
vertexLabelAPI.create(vertexLabel);
});
Utils.assertResponseError(400, () -> {
VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").usePrimaryKeyId().build();
vertexLabelAPI.create(vertexLabel);
});
}
use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.
the class VertexLabelApiTest method testAppend.
@Test
public void testAppend() {
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");
Set<String> nullableKeys = ImmutableSet.of();
Assert.assertEquals(props, vertexLabel1.properties());
Assert.assertEquals(nullableKeys, vertexLabel1.nullableKeys());
VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("city").nullableKeys("city").build();
vertexLabel2 = vertexLabelAPI.append(vertexLabel2);
Assert.assertEquals("person", vertexLabel2.name());
Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel2.idStrategy());
props = ImmutableSet.of("name", "age", "city");
nullableKeys = ImmutableSet.of("city");
Assert.assertEquals(props, vertexLabel2.properties());
Assert.assertEquals(nullableKeys, vertexLabel2.nullableKeys());
}
Aggregations