use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testAddEdgeLabelWithUserData.
@Test
public void testAddEdgeLabelWithUserData() {
EdgeLabel father = schema().edgeLabel("father").link("person", "person").properties("weight").userdata("multiplicity", "one-to-many").build();
father = edgeLabelAPI.create(father);
Assert.assertEquals(2, father.userdata().size());
Assert.assertEquals("one-to-many", father.userdata().get("multiplicity"));
String time = (String) father.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
EdgeLabel write = schema().edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("multiplicity", "many-to-many").build();
write = edgeLabelAPI.create(write);
// The same key user data will be overwritten
Assert.assertEquals(2, write.userdata().size());
Assert.assertEquals("many-to-many", write.userdata().get("multiplicity"));
time = (String) write.userdata().get("~create_time");
createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testCreateWithEnableLabelIndexFalse.
@Test
public void testCreateWithEnableLabelIndexFalse() {
EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").singleTime().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 testCreateWithUndefinedSortKey.
@Test
public void testCreateWithUndefinedSortKey() {
EdgeLabel edgeLabel = schema().edgeLabel("created").sourceLabel("person").targetLabel("software").multiTimes().properties("date", "city").sortKeys("undefined").build();
Utils.assertResponseError(400, () -> {
edgeLabelAPI.create(edgeLabel);
});
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testEliminate.
@Test
public void testEliminate() {
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").build();
Utils.assertResponseError(400, () -> {
edgeLabelAPI.eliminate(edgeLabel2);
});
}
use of com.baidu.hugegraph.structure.schema.EdgeLabel in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelApiTest method testGet.
@Test
public void testGet() {
EdgeLabel edgeLabel1 = edgeLabelAPI.create(fillEdgeLabel.apply("created"));
EdgeLabel edgeLabel2 = edgeLabelAPI.get("created");
Assert.assertEquals(edgeLabel1.name(), edgeLabel2.name());
Assert.assertEquals(edgeLabel1.sourceLabel(), edgeLabel2.sourceLabel());
Assert.assertEquals(edgeLabel1.targetLabel(), edgeLabel2.targetLabel());
Assert.assertEquals(edgeLabel1.frequency(), edgeLabel2.frequency());
Assert.assertEquals(edgeLabel1.properties(), edgeLabel2.properties());
}
Aggregations