Search in sources :

Example 61 with SchemaManager

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

Example 62 with SchemaManager

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

Example 63 with SchemaManager

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

Example 64 with SchemaManager

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

Example 65 with SchemaManager

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();
    });
}
Also used : 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