Search in sources :

Example 41 with VertexLabel

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

the class VertexLabelApiTest method testCreateExistedVertexLabel.

@Test
public void testCreateExistedVertexLabel() {
    VertexLabel vertexLabel = new VertexLabel("name");
    vertexLabelAPI.create(vertexLabel);
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(new VertexLabel("name"));
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 42 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithInvalidName.

@Test
public void testCreateWithInvalidName() {
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(new VertexLabel(""));
    });
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(new VertexLabel(" "));
    });
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.create(new VertexLabel("    "));
    });
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Test(org.junit.Test)

Example 43 with VertexLabel

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

the class VertexLabelApiTest method testCreateWithUndefinedPrimaryKey.

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

Example 44 with VertexLabel

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

the class VertexLabelApiTest method testAddVertexLabelWithUserData.

@Test
public void testAddVertexLabelWithUserData() {
    VertexLabel player = schema().vertexLabel("player").properties("name").userdata("super_vl", "person").build();
    player = vertexLabelAPI.create(player);
    Assert.assertEquals(2, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
    String time = (String) player.userdata().get("~create_time");
    Date createTime = DateUtil.parse(time);
    Assert.assertTrue(createTime.before(DateUtil.now()));
    VertexLabel runner = schema().vertexLabel("runner").properties("name").userdata("super_vl", "person").userdata("super_vl", "player").build();
    runner = vertexLabelAPI.create(runner);
    // The same key user data will be overwritten
    Assert.assertEquals(2, runner.userdata().size());
    Assert.assertEquals("player", runner.userdata().get("super_vl"));
    time = (String) runner.userdata().get("~create_time");
    createTime = DateUtil.parse(time);
    Assert.assertTrue(createTime.before(DateUtil.now()));
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) Date(java.util.Date) Test(org.junit.Test)

Example 45 with VertexLabel

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

the class VertexLabelApiTest method testAppendWithUndefinedNullabelKeys.

@Test
public void testAppendWithUndefinedNullabelKeys() {
    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").nullableKeys("undefined").build();
    Utils.assertResponseError(400, () -> {
        vertexLabelAPI.append(vertexLabel2);
    });
}
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