Search in sources :

Example 1 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithTtl.

@Test
public void testCreateWithTtl() {
    VertexLabel vertexLabel = schema().vertexLabel("person1").useAutomaticId().properties("name", "age", "date").build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person1", vertexLabel.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
    Assert.assertEquals(true, vertexLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("name", "age", "date");
    Assert.assertEquals(props, vertexLabel.properties());
    Assert.assertEquals(0L, vertexLabel.ttl());
    Assert.assertNull(vertexLabel.ttlStartTime());
    vertexLabel = schema().vertexLabel("person2").useAutomaticId().properties("name", "age", "date").ttl(3000L).build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person2", vertexLabel.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
    Assert.assertEquals(true, vertexLabel.enableLabelIndex());
    Assert.assertEquals(props, vertexLabel.properties());
    Assert.assertEquals(3000L, vertexLabel.ttl());
    Assert.assertNull(vertexLabel.ttlStartTime());
    vertexLabel = schema().vertexLabel("person3").useAutomaticId().properties("name", "age", "date").ttl(3000L).ttlStartTime("date").build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person3", vertexLabel.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
    Assert.assertEquals(true, vertexLabel.enableLabelIndex());
    Assert.assertEquals(props, vertexLabel.properties());
    Assert.assertEquals(3000L, vertexLabel.ttl());
    Assert.assertEquals("date", vertexLabel.ttlStartTime());
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 2 with VertexLabel

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

the class VertexLabelApiTest method testListByNames.

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

Example 3 with VertexLabel

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

the class VertexLabelApiTest method testAppendWithUndefinedPropertyKey.

@Test
public void testAppendWithUndefinedPropertyKey() {
    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");
    Assert.assertEquals(props, vertexLabel1.properties());
    VertexLabel vertexLabel2 = schema().vertexLabel("person").properties("undefined").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.append(vertexLabel2);
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 4 with VertexLabel

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

the class VertexLabelApiTest method testCreate.

@Test
public void testCreate() {
    VertexLabel vertexLabel = schema().vertexLabel("person").useAutomaticId().properties("name", "age", "city").build();
    vertexLabel = vertexLabelAPI.create(vertexLabel);
    Assert.assertEquals("person", vertexLabel.name());
    Assert.assertEquals(IdStrategy.AUTOMATIC, vertexLabel.idStrategy());
    Assert.assertEquals(true, 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 5 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithNonNullKeysIntersectPrimaryKeys.

@Test
public void testCreateWithNonNullKeysIntersectPrimaryKeys() {
    VertexLabel vertexLabel1 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name").nullableKeys("name").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(vertexLabel1);
    });
    VertexLabel vertexLabel2 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name", "age").nullableKeys("name").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(vertexLabel2);
    });
    VertexLabel vertexLabel3 = schema().vertexLabel("person").usePrimaryKeyId().properties("name", "age", "city").primaryKeys("name").nullableKeys("name", "age").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(vertexLabel3);
    });
}
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