Search in sources :

Example 56 with SchemaManager

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();
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 57 with SchemaManager

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());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 58 with SchemaManager

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();
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 59 with SchemaManager

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();
    });
}
Also used : SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 60 with SchemaManager

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());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Aggregations

SchemaManager (com.baidu.hugegraph.schema.SchemaManager)261 Test (org.junit.Test)227 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)90 HugeGraph (com.baidu.hugegraph.HugeGraph)76 FakeVertex (com.baidu.hugegraph.testutil.FakeObjects.FakeVertex)40 Edge (org.apache.tinkerpop.gremlin.structure.Edge)30 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)27 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)22 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)20 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)19 FakeEdge (com.baidu.hugegraph.testutil.FakeObjects.FakeEdge)19 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)15 Id (com.baidu.hugegraph.backend.id.Id)12 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)8 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)7 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)7 Date (java.util.Date)6 Before (org.junit.Before)6 HashSet (java.util.HashSet)3 HugeException (com.baidu.hugegraph.HugeException)2