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()));
}
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());
}
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);
}
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()));
}
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());
}
Aggregations