use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAppendVertexLabelWithUserdata.
@Test
public void testAppendVertexLabelWithUserdata() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").create();
Assert.assertEquals(2, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
player = schema.vertexLabel("player").userdata("icon", "picture1").append();
Assert.assertEquals(3, player.userdata().size());
Assert.assertEquals("person", player.userdata().get("super_vl"));
Assert.assertEquals("picture1", player.userdata().get("icon"));
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testCreateTime.
@Test
public void testCreateTime() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
VertexLabel person = schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").create();
Date createTime = (Date) person.userdata().get(Userdata.CREATE_TIME);
Date now = DateUtil.now();
Assert.assertFalse(createTime.after(now));
person = schema.getVertexLabel("person");
createTime = (Date) person.userdata().get(Userdata.CREATE_TIME);
Assert.assertFalse(createTime.after(now));
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAppendVertexLabelWithNullableKeysInOriginProperties.
@Test
public void testAppendVertexLabelWithNullableKeysInOriginProperties() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("age").create();
VertexLabel person = schema.vertexLabel("person").nullableKeys("city").append();
Assert.assertNotNull(person);
Assert.assertEquals("person", person.name());
Assert.assertEquals(3, person.properties().size());
assertContainsPk(person.properties(), "name", "age", "city");
Assert.assertEquals(1, person.primaryKeys().size());
assertContainsPk(person.primaryKeys(), "name");
Assert.assertEquals(2, person.nullableKeys().size());
assertContainsPk(person.nullableKeys(), "age", "city");
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class VertexLabelCoreTest method testAddVertexLabelWithEnableLabelIndex.
@Test
public void testAddVertexLabelWithEnableLabelIndex() {
super.initPropertyKeys();
SchemaManager schema = graph().schema();
VertexLabel person = schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("city").enableLabelIndex(true).create();
Assert.assertEquals(true, person.enableLabelIndex());
graph().addVertex(T.label, "person", "name", "marko", "age", 18);
graph().addVertex(T.label, "person", "name", "josh", "age", 20);
graph().tx().commit();
List<Vertex> persons = graph().traversal().V().hasLabel("person").toList();
Assert.assertEquals(2, persons.size());
}
use of com.baidu.hugegraph.schema.VertexLabel in project incubator-hugegraph by apache.
the class RamTableTest method testAddInvalidVertexOrEdge.
@Test
public void testAddInvalidVertexOrEdge() {
HugeGraph graph = this.graph();
VertexLabel vl3 = graph.vertexLabel("vl3");
EdgeLabel el3 = graph.edgeLabel("el3");
VertexLabel vl2 = graph.vertexLabel("vl2");
EdgeLabel el2 = graph.edgeLabel("el2");
RamTable table = new RamTable(graph, VERTEX_SIZE, EDGE_SIZE);
HugeVertex ownerVertex = new HugeVertex(graph, IdGenerator.of(1), vl3);
HugeEdge edge1 = HugeEdge.constructEdge(ownerVertex, true, el3, "marko", IdGenerator.of(2));
Assert.assertThrows(HugeException.class, () -> {
table.addEdge(true, edge1);
}, e -> {
Assert.assertContains("Only edge label without sortkey is " + "supported by ramtable, but got 'el3(id=3)'", e.getMessage());
});
HugeVertex v1 = new HugeVertex(graph, IdGenerator.of("s1"), vl2);
HugeEdge edge2 = HugeEdge.constructEdge(v1, true, el2, "marko", IdGenerator.of("s2"));
Assert.assertThrows(HugeException.class, () -> {
table.addEdge(true, edge2);
}, e -> {
Assert.assertContains("Only number id is supported by ramtable, " + "but got string id 's1'", e.getMessage());
});
HugeVertex v2 = new HugeVertex(graph, IdGenerator.of(2), vl2);
HugeEdge edge3 = HugeEdge.constructEdge(v2, true, el2, "marko", IdGenerator.of("s2"));
Assert.assertThrows(HugeException.class, () -> {
table.addEdge(true, edge3);
}, e -> {
Assert.assertContains("Only number id is supported by ramtable, " + "but got string id 's2'", e.getMessage());
});
}
Aggregations