use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testRemoveVertexLabelWithVertex.
@Test
public void testRemoveVertexLabelWithVertex() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("city").create();
graph().addVertex(T.label, "person", "name", "marko", "age", 22);
graph().addVertex(T.label, "person", "name", "jerry", "age", 5);
graph().addVertex(T.label, "person", "name", "tom", "age", 8);
graph().tx().commit();
List<Vertex> vertex = graph().traversal().V().hasLabel("person").toList();
Assert.assertNotNull(vertex);
Assert.assertEquals(3, vertex.size());
schema.vertexLabel("person").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getVertexLabel("person");
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph().traversal().V().hasLabel("person").toList();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAppendVertexLabelWithPkAsNullableProperties.
@Test
public void testAppendVertexLabelWithPkAsNullableProperties() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age").primaryKeys("name").create();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person").properties("name", "city").nullableKeys("name", "city").append();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithPrimaryKeyAssignedMultiTimes.
@Test
public void testAddVertexLabelWithPrimaryKeyAssignedMultiTimes() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").primaryKeys("age").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexWithCustomizeIdStrategyAndNotPassedPk.
@Test
public void testAddVertexWithCustomizeIdStrategyAndNotPassedPk() {
super.initPropertyKeys();
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
VertexLabel person = schema.vertexLabel("person").useCustomizeStringId().properties("name", "age").create();
Assert.assertEquals(IdStrategy.CUSTOMIZE_STRING, person.idStrategy());
VertexLabel player = schema.vertexLabel("player").useCustomizeNumberId().properties("name", "age").create();
Assert.assertEquals(IdStrategy.CUSTOMIZE_NUMBER, player.idStrategy());
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithNullableKeysNotInProperties.
@Test
public void testAddVertexLabelWithNullableKeysNotInProperties() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("time").create();
});
}
Aggregations