Search in sources :

Example 11 with EdgeLabel

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

the class EdgeLabelTest method testListByNames.

@Test
public void testListByNames() {
    SchemaManager schema = schema();
    EdgeLabel father = schema.edgeLabel("father").link("person", "person").create();
    EdgeLabel write = schema.edgeLabel("write").link("person", "book").create();
    List<EdgeLabel> edgeLabels;
    edgeLabels = schema.getEdgeLabels(ImmutableList.of("father"));
    Assert.assertEquals(1, edgeLabels.size());
    assertContains(edgeLabels, father);
    edgeLabels = schema.getEdgeLabels(ImmutableList.of("write"));
    Assert.assertEquals(1, edgeLabels.size());
    assertContains(edgeLabels, write);
    edgeLabels = schema.getEdgeLabels(ImmutableList.of("father", "write"));
    Assert.assertEquals(2, edgeLabels.size());
    assertContains(edgeLabels, father);
    assertContains(edgeLabels, write);
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 12 with EdgeLabel

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

the class EdgeLabelTest method testResetEdgeLabelId.

@Test
public void testResetEdgeLabelId() {
    SchemaManager schema = schema();
    EdgeLabel write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("icon", "picture2").create();
    Assert.assertTrue(write.id() > 0);
    write.resetId();
    Assert.assertEquals(0L, write.id());
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 13 with EdgeLabel

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

the class EdgeLabelApiTest method testCreateWithUndefinedPropertyKey.

@Test
public void testCreateWithUndefinedPropertyKey() {
    EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("undefined", "city").build();
    Utils.assertResponseError(400, () -> {
        edgeLabelAPI.create(edgeLabel);
    });
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 14 with EdgeLabel

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

the class EdgeLabelApiTest method testCreateWithNonNullKeysIntersectSortKeys.

@Test
public void testCreateWithNonNullKeysIntersectSortKeys() {
    EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").multiTimes().properties("date", "city").sortKeys("date").nullableKeys("date").build();
    Utils.assertResponseError(400, () -> {
        edgeLabelAPI.create(edgeLabel);
    });
    Utils.assertResponseError(400, () -> {
        edgeLabelAPI.create(edgeLabel);
    });
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 15 with EdgeLabel

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

the class EdgeLabelApiTest method testCreateWithUndefinedNullableKeys.

@Test
public void testCreateWithUndefinedNullableKeys() {
    EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date", "city").nullableKeys("undefined").build();
    Utils.assertResponseError(400, () -> {
        edgeLabelAPI.create(edgeLabel);
    });
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Aggregations

EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)44 Test (org.junit.Test)31 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)9 HugeClient (com.baidu.hugegraph.driver.HugeClient)8 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)4 ServerException (com.baidu.hugegraph.exception.ServerException)4 Date (java.util.Date)4 RestResult (com.baidu.hugegraph.rest.RestResult)3 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)3 ArrayList (java.util.ArrayList)3 Task (com.baidu.hugegraph.structure.Task)2 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)1 EdgeLabelEntity (com.baidu.hugegraph.entity.schema.EdgeLabelEntity)1 EdgeLabelStyle (com.baidu.hugegraph.entity.schema.EdgeLabelStyle)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)1 HashSet (java.util.HashSet)1