use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithoutPrimaryKey.
@Test
public void testAddVertexLabelWithoutPrimaryKey() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexWithPrimaryKeyIdStrategyAndPassedPk.
@Test
public void testAddVertexWithPrimaryKeyIdStrategyAndPassedPk() {
super.initPropertyKeys();
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
VertexLabel person = schema.vertexLabel("person").usePrimaryKeyId().properties("name", "age").primaryKeys("name").create();
Assert.assertEquals(IdStrategy.PRIMARY_KEY, person.idStrategy());
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithUndefinedNullableKeys.
@Test
public void testAddVertexLabelWithUndefinedNullableKeys() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("undefined").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithIllegalName.
@Test
public void testAddVertexLabelWithIllegalName() {
SchemaManager schema = graph().schema();
// Empty string
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("").create();
});
// One space
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel(" ").create();
});
// Two spaces
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel(" ").create();
});
// Multi spaces
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel(" ").create();
});
// Start with '~'
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("~").create();
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("~ ").create();
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.vertexLabel("~x").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithNonPKIdStrategyWithoutProperty.
@Test
public void testAddVertexLabelWithNonPKIdStrategyWithoutProperty() {
HugeGraph graph = graph();
SchemaManager schema = graph.schema();
VertexLabel person1 = schema.vertexLabel("person1").useAutomaticId().create();
Assert.assertEquals(IdStrategy.AUTOMATIC, person1.idStrategy());
Assert.assertTrue(person1.properties().isEmpty());
VertexLabel person2 = schema.vertexLabel("person2").useCustomizeStringId().create();
Assert.assertEquals(IdStrategy.CUSTOMIZE_STRING, person2.idStrategy());
Assert.assertTrue(person2.properties().isEmpty());
VertexLabel person3 = schema.vertexLabel("person3").useCustomizeNumberId().create();
Assert.assertEquals(IdStrategy.CUSTOMIZE_NUMBER, person3.idStrategy());
Assert.assertTrue(person3.properties().isEmpty());
}
Aggregations