Search in sources :

Example 6 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testAddVertexLabelWith2PrimaryKey.

@Test
public void testAddVertexLabelWith2PrimaryKey() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    VertexLabel person = schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name", "age").create();
    Assert.assertNotNull(person);
    Assert.assertEquals("person", person.name());
    Assert.assertEquals(3, person.properties().size());
    assertContainsPk(person.properties(), "name", "age", "city");
    Assert.assertEquals(2, person.primaryKeys().size());
    assertContainsPk(person.primaryKeys(), "name", "age");
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 7 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testAddVertexWithAutomaticIdStrategyButPassedPk.

@Test
public void testAddVertexWithAutomaticIdStrategyButPassedPk() {
    HugeGraph graph = graph();
    SchemaManager schema = graph.schema();
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        schema.vertexLabel("person").useAutomaticId().properties("name", "age").primaryKeys("name").create();
    });
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 8 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testAddVertexLabel.

@Test
public void testAddVertexLabel() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    VertexLabel person = schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
    Assert.assertNotNull(person);
    Assert.assertEquals("person", person.name());
    Assert.assertEquals(3, person.properties().size());
    assertContainsPk(person.properties(), "name", "age", "city");
    Assert.assertEquals(1, person.primaryKeys().size());
    assertContainsPk(person.primaryKeys(), "name");
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 9 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testAppendVertexLabelWithNullableKeysInAppendProperties.

@Test
public void testAppendVertexLabelWithNullableKeysInAppendProperties() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    schema.vertexLabel("person").properties("name", "age").primaryKeys("name").create();
    VertexLabel person = schema.vertexLabel("person").properties("city").nullableKeys("city").append();
    Assert.assertNotNull(person);
    Assert.assertEquals("person", person.name());
    Assert.assertEquals(3, person.properties().size());
    assertContainsPk(person.properties(), "name", "age", "city");
    Assert.assertEquals(1, person.primaryKeys().size());
    assertContainsPk(person.primaryKeys(), "name");
    Assert.assertEquals(1, person.nullableKeys().size());
    assertContainsPk(person.nullableKeys(), "city");
}
Also used : VertexLabel(com.baidu.hugegraph.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.schema.SchemaManager) Test(org.junit.Test)

Example 10 with SchemaManager

use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.

the class VertexLabelCoreTest method testEliminateVertexLabelWithUserdata.

@Test
public void testEliminateVertexLabelWithUserdata() {
    super.initPropertyKeys();
    SchemaManager schema = graph().schema();
    VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").userdata("icon", "picture1").create();
    Assert.assertEquals(3, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
    Assert.assertEquals("picture1", player.userdata().get("icon"));
    player = schema.vertexLabel("player").userdata("icon", "").eliminate();
    Assert.assertEquals(2, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
}
Also used : 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