Search in sources :

Example 36 with EdgeLabel

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

the class EdgeLabelApiTest method testCreate.

@Test
public void testCreate() {
    EdgeLabel edgeLabel = fillEdgeLabel.apply("created");
    edgeLabel = edgeLabelAPI.create(edgeLabel);
    Assert.assertEquals("created", edgeLabel.name());
    Assert.assertEquals("person", edgeLabel.sourceLabel());
    Assert.assertEquals("software", edgeLabel.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel.frequency());
    Assert.assertEquals(true, edgeLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("date", "city");
    Assert.assertTrue(props.size() == edgeLabel.properties().size());
    Assert.assertTrue(props.containsAll(edgeLabel.properties()));
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 37 with EdgeLabel

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

the class EdgeLabelApiTest method testCreateWithTtl.

@Test
public void testCreateWithTtl() {
    EdgeLabel edgeLabel = schema().edgeLabel("created1").sourceLabel("person").targetLabel("software").frequency(Frequency.SINGLE).properties("date", "city").build();
    edgeLabel = edgeLabelAPI.create(edgeLabel);
    Assert.assertEquals("created1", edgeLabel.name());
    Assert.assertEquals("person", edgeLabel.sourceLabel());
    Assert.assertEquals("software", edgeLabel.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel.frequency());
    Assert.assertEquals(true, edgeLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("date", "city");
    Assert.assertTrue(props.size() == edgeLabel.properties().size());
    Assert.assertTrue(props.containsAll(edgeLabel.properties()));
    Assert.assertEquals(0L, edgeLabel.ttl());
    Assert.assertNull(edgeLabel.ttlStartTime());
    edgeLabel = schema().edgeLabel("created2").sourceLabel("person").targetLabel("software").frequency(Frequency.SINGLE).properties("date", "city").ttl(3000L).build();
    edgeLabel = edgeLabelAPI.create(edgeLabel);
    Assert.assertEquals("created2", edgeLabel.name());
    Assert.assertEquals("person", edgeLabel.sourceLabel());
    Assert.assertEquals("software", edgeLabel.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel.frequency());
    Assert.assertEquals(true, edgeLabel.enableLabelIndex());
    Assert.assertTrue(props.size() == edgeLabel.properties().size());
    Assert.assertTrue(props.containsAll(edgeLabel.properties()));
    Assert.assertEquals(3000L, edgeLabel.ttl());
    Assert.assertNull(edgeLabel.ttlStartTime());
    edgeLabel = schema().edgeLabel("created3").sourceLabel("person").targetLabel("software").frequency(Frequency.SINGLE).properties("date", "city").ttl(3000L).ttlStartTime("date").build();
    edgeLabel = edgeLabelAPI.create(edgeLabel);
    Assert.assertEquals("created3", edgeLabel.name());
    Assert.assertEquals("person", edgeLabel.sourceLabel());
    Assert.assertEquals("software", edgeLabel.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel.frequency());
    Assert.assertEquals(true, edgeLabel.enableLabelIndex());
    Assert.assertTrue(props.size() == edgeLabel.properties().size());
    Assert.assertTrue(props.containsAll(edgeLabel.properties()));
    Assert.assertEquals(3000L, edgeLabel.ttl());
    Assert.assertEquals("date", edgeLabel.ttlStartTime());
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 38 with EdgeLabel

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

the class EdgeLabelApiTest method testList.

@Test
public void testList() {
    EdgeLabel edgeLabel1 = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date", "city").build();
    edgeLabel1 = edgeLabelAPI.create(edgeLabel1);
    EdgeLabel edgeLabel2 = schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").singleTime().properties("date").build();
    edgeLabel2 = edgeLabelAPI.create(edgeLabel2);
    List<EdgeLabel> edgeLabels = edgeLabelAPI.list();
    Assert.assertEquals(2, edgeLabels.size());
    assertContains(edgeLabels, edgeLabel1);
    assertContains(edgeLabels, edgeLabel2);
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 39 with EdgeLabel

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

the class EdgeLabelApiTest method testCreateWithFrequency.

@Test
public void testCreateWithFrequency() {
    EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").frequency(Frequency.SINGLE).properties("date", "city").enableLabelIndex(false).create();
    Assert.assertEquals("created", edgeLabel.name());
    Assert.assertEquals("person", edgeLabel.sourceLabel());
    Assert.assertEquals("software", edgeLabel.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel.frequency());
    Assert.assertEquals(false, edgeLabel.enableLabelIndex());
    Set<String> props = ImmutableSet.of("date", "city");
    Assert.assertTrue(props.size() == edgeLabel.properties().size());
    Assert.assertTrue(props.containsAll(edgeLabel.properties()));
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) Test(org.junit.Test)

Example 40 with EdgeLabel

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

the class EdgeLabelApiTest method testAppend.

@Test
public void testAppend() {
    EdgeLabel edgeLabel1 = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date").build();
    edgeLabel1 = edgeLabelAPI.create(edgeLabel1);
    Assert.assertEquals("created", edgeLabel1.name());
    Assert.assertEquals("person", edgeLabel1.sourceLabel());
    Assert.assertEquals("software", edgeLabel1.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel1.frequency());
    Set<String> props = ImmutableSet.of("date");
    Assert.assertEquals(props, edgeLabel1.properties());
    EdgeLabel edgeLabel2 = schema().edgeLabel("created").properties("city").nullableKeys("city").build();
    edgeLabel2 = edgeLabelAPI.append(edgeLabel2);
    Assert.assertEquals("created", edgeLabel2.name());
    Assert.assertEquals("person", edgeLabel2.sourceLabel());
    Assert.assertEquals("software", edgeLabel2.targetLabel());
    Assert.assertEquals(Frequency.SINGLE, edgeLabel2.frequency());
    props = ImmutableSet.of("date", "city");
    Set<String> nullableKeys = ImmutableSet.of("city");
    Assert.assertEquals(props, edgeLabel2.properties());
    Assert.assertEquals(nullableKeys, edgeLabel2.nullableKeys());
}
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