Search in sources :

Example 6 with VertexLabel

use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.

the class VertexLabelApiTest method testEliminate.

@Test
public void testEliminate() {
    VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
    vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
    Assert.assertEquals("person", vertexLabel1.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel1.idStrategy());
    Set<String> props = ImmutableSet.of("name", "age", "city");
    Assert.assertEquals(props, vertexLabel1.properties());
    VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("city").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.eliminate(vertexLabel2);
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 7 with VertexLabel

use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.

the class VertexLabelApiTest method testCreateWithEnableLabelIndexFalse.

@Test
public void testCreateWithEnableLabelIndexFalse() {
    VertexLabel vertexLabel = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").enableLabelIndex(false).build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person", vertexLabel.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
    Assert.assertEquals(false, vertexLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("name", "age", "city");
    Assert.assertEquals(props, vertexLabel.properties());
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 8 with VertexLabel

use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.

the class VertexLabelApiTest method testCreateWithUndefinedPropertyKey.

@Test
public void testCreateWithUndefinedPropertyKey() {
    VertexLabel vertexLabel = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "undefined").primaryKeys("name").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(vertexLabel);
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 9 with VertexLabel

use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.

the class VertexLabelApiTest method testCreateWithUnmatchIdStrategyAndProperties.

@Test
public void testCreateWithUnmatchIdStrategyAndProperties() {
    Utils.assertResponseError(400, () -> {
        VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").useAutomaticId().primaryKeys("name").build();
        vertexLabelAPI.create(vertexLabel);
    });
    Utils.assertResponseError(400, () -> {
        VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").useCustomizeStringId().primaryKeys("name").build();
        vertexLabelAPI.create(vertexLabel);
    });
    Utils.assertResponseError(400, () -> {
        VertexLabel vertexLabel = schema().vertexLabel("person").properties("name", "age", "city").usePrimaryKeyId().build();
        vertexLabelAPI.create(vertexLabel);
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 10 with VertexLabel

use of com.baidu.hugegraph.structure.schema.VertexLabel in project incubator-hugegraph-toolchain by apache.

the class VertexLabelApiTest method testAppend.

@Test
public void testAppend() {
    VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age").build();
    vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
    Assert.assertEquals("person", vertexLabel1.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel1.idStrategy());
    Set<String> props = ImmutableSet.of("name", "age");
    Set<String> nullableKeys = ImmutableSet.of();
    Assert.assertEquals(props, vertexLabel1.properties());
    Assert.assertEquals(nullableKeys, vertexLabel1.nullableKeys());
    VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("city").nullableKeys("city").build();
    vertexLabel2 = vertexLabelAPI.append(vertexLabel2);
    Assert.assertEquals("person", vertexLabel2.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel2.idStrategy());
    props = ImmutableSet.of("name", "age", "city");
    nullableKeys = ImmutableSet.of("city");
    Assert.assertEquals(props, vertexLabel2.properties());
    Assert.assertEquals(nullableKeys, vertexLabel2.nullableKeys());
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Aggregations

VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)46 Test (org.junit.Test)31 HugeClient (com.baidu.hugegraph.driver.HugeClient)7 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)7 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)5 ServerException (com.baidu.hugegraph.exception.ServerException)5 Edge (com.baidu.hugegraph.structure.graph.Edge)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 RestResult (com.baidu.hugegraph.rest.RestResult)3 Vertex (com.baidu.hugegraph.structure.graph.Vertex)3 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)3 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)2 VertexLabelEntity (com.baidu.hugegraph.entity.schema.VertexLabelEntity)1 VertexLabelStyle (com.baidu.hugegraph.entity.schema.VertexLabelStyle)1 Record (com.baidu.hugegraph.loader.builder.Record)1 VertexBuilder (com.baidu.hugegraph.loader.builder.VertexBuilder)1 ParseException (com.baidu.hugegraph.loader.exception.ParseException)1 ElementMapping (com.baidu.hugegraph.loader.mapping.ElementMapping)1