use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithNotExistProperty.
@Test
public void testAddEdgeLabelWithNotExistProperty() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.edgeLabel("look").properties("date").link("person", "book").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testRemoveEdgeLabel.
@Test
public void testRemoveEdgeLabel() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("name", "contribution").primaryKeys("name").create();
schema.edgeLabel("look").link("person", "book").properties("time", "city").create();
Assert.assertNotNull(schema.getEdgeLabel("look"));
schema.edgeLabel("look").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getEdgeLabel("look");
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testRemoveEdgeLabelWithEdge.
@Test
public void testRemoveEdgeLabelWithEdge() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("city").create();
schema.vertexLabel("book").properties("name").primaryKeys("name").create();
schema.edgeLabel("write").link("person", "book").properties("time", "weight").create();
Vertex marko = graph().addVertex(T.label, "person", "name", "marko", "age", 22);
Vertex java = graph().addVertex(T.label, "book", "name", "java in action");
Vertex hadoop = graph().addVertex(T.label, "book", "name", "hadoop mapreduce");
marko.addEdge("write", java, "time", "2016-12-12", "weight", 0.3);
marko.addEdge("write", hadoop, "time", "2014-2-28", "weight", 0.5);
graph().tx().commit();
List<Edge> edges = graph().traversal().E().hasLabel("write").toList();
Assert.assertNotNull(edges);
Assert.assertEquals(2, edges.size());
schema.edgeLabel("write").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getEdgeLabel("write");
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
graph().traversal().E().hasLabel("write").toList();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithUndefinedNullableKeys.
@Test
public void testAddEdgeLabelWithUndefinedNullableKeys() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("author").properties("id", "name").primaryKeys("id").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
Assert.assertThrows(IllegalArgumentException.class, () -> {
schema.edgeLabel("look").properties("time", "weight").nullableKeys("undefined").link("person", "book").create();
});
}
use of com.baidu.hugegraph.schema.SchemaManager in project incubator-hugegraph by apache.
the class EdgeLabelCoreTest method testAddEdgeLabelWithNullableKeys.
@Test
public void testAddEdgeLabelWithNullableKeys() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
schema.vertexLabel("book").properties("id", "name").primaryKeys("id").create();
EdgeLabel look = schema.edgeLabel("look").properties("time", "weight").nullableKeys("weight").link("person", "book").create();
Assert.assertNotNull(look);
Assert.assertEquals("look", look.name());
assertVLEqual("person", look.sourceLabel());
assertVLEqual("book", look.targetLabel());
Assert.assertEquals(2, look.properties().size());
assertContainsPk(look.properties(), "time", "weight");
Assert.assertEquals(1, look.nullableKeys().size());
assertContainsPk(look.nullableKeys(), "weight");
}
Aggregations