Search in sources :

Example 11 with VertexLabel

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

the class VertexLabelApiTest method testList.

@Test
public void testList() {
    VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
    vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
    VertexLabel vertexLabel2 = schema().vertexLabel("software").useCustomizeStringId().properties("name", "lang", "price").build();
    vertexLabel2 = vertexLabelAPI.create(vertexLabel2);
    List<VertexLabel> vertexLabels = vertexLabelAPI.list();
    Assert.assertEquals(2, vertexLabels.size());
    assertContains(vertexLabels, vertexLabel1);
    assertContains(vertexLabels, vertexLabel2);
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 12 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithUndefinedNullableKeys.

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

Example 13 with VertexLabel

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

the class VertexLabelApiTest method testDelete.

@Test
public void testDelete() {
    VertexLabel vertexLabel = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
    vertexLabelAPI.create(vertexLabel);
    long taskId = vertexLabelAPI.delete("person");
    waitUntilTaskCompleted(taskId);
    Utils.assertResponseError(404, () -> {
        vertexLabelAPI.get("person");
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 14 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithUuidIdStrategy.

@Test
public void testCreateWithUuidIdStrategy() {
    VertexLabel vertexLabel = schema().vertexLabel("person").useCustomizeUuidId().properties("name", "age", "city").build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person", vertexLabel.name());
    Assert.assertEquals(IdStrategy.CUSTOMIZE_UUID, vertexLabel.idStrategy());
    Assert.assertEquals(true, vertexLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("name", "age", "city");
    Assert.assertEquals(props, vertexLabel.properties());
    vertexLabel = schema().vertexLabel("person1").idStrategy(IdStrategy.CUSTOMIZE_UUID).properties("name", "age", "city").build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person1", vertexLabel.name());
    Assert.assertEquals(IdStrategy.CUSTOMIZE_UUID, vertexLabel.idStrategy());
    Assert.assertEquals(true, vertexLabel.enableLabelIndex());
    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 15 with VertexLabel

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

the class VertexLabelApiTest method testGet.

@Test
public void testGet() {
    VertexLabel vertexLabel1 = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
    vertexLabel1 = vertexLabelAPI.create(vertexLabel1);
    VertexLabel vertexLabel2 = vertexLabelAPI.get("person");
    Assert.assertEquals(vertexLabel1.name(), vertexLabel2.name());
    Assert.assertEquals(vertexLabel1.idStrategy(), vertexLabel2.idStrategy());
    Assert.assertEquals(vertexLabel1.properties(), vertexLabel2.properties());
}
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