use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testSetCheckExist.
@Test
public void testSetCheckExist() {
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.checkExist());
write.checkExist(false);
Assert.assertFalse(write.checkExist());
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testAppendEdgeLabelWithUserData.
@Test
public void testAppendEdgeLabelWithUserData() {
SchemaManager schema = schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("city").ifNotExist().create();
EdgeLabel father = schema.edgeLabel("father").link("person", "person").properties("weight").create();
Assert.assertEquals(1, father.userdata().size());
String time = (String) father.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
father = schema.edgeLabel("father").userdata("multiplicity", "one-to-many").append();
Assert.assertEquals(2, father.userdata().size());
Assert.assertEquals("one-to-many", father.userdata().get("multiplicity"));
time = (String) father.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testListByNames.
@Test
public void testListByNames() {
EdgeLabel created = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().properties("date", "city").build();
created = edgeLabelAPI.create(created);
EdgeLabel knows = schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").singleTime().properties("date").build();
knows = edgeLabelAPI.create(knows);
List<EdgeLabel> edgeLabels;
edgeLabels = edgeLabelAPI.list(ImmutableList.of("created"));
Assert.assertEquals(1, edgeLabels.size());
assertContains(edgeLabels, created);
edgeLabels = edgeLabelAPI.list(ImmutableList.of("knows"));
Assert.assertEquals(1, edgeLabels.size());
assertContains(edgeLabels, knows);
edgeLabels = edgeLabelAPI.list(ImmutableList.of("created", "knows"));
Assert.assertEquals(2, edgeLabels.size());
assertContains(edgeLabels, created);
assertContains(edgeLabels, knows);
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testAppendWithUndefinedPropertyKey.
@Test
public void testAppendWithUndefinedPropertyKey() {
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("undefined").build();
Utils.assertResponseError(400, () -> {
edgeLabelAPI.append(edgeLabel2);
});
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testAppendWithUndefinedNullableKeys.
@Test
public void testAppendWithUndefinedNullableKeys() {
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").nullableKeys("undefined").build();
Utils.assertResponseError(400, () -> {
edgeLabelAPI.append(edgeLabel2);
});
}
Aggregations