use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testEliminateEdgeLabelWithUserData.
@Test
public void testEliminateEdgeLabelWithUserData() {
SchemaManager schema = schema();
EdgeLabel write = schema.edgeLabel("write").link("person", "book").properties("date", "weight").userdata("multiplicity", "one-to-many").userdata("icon", "picture2").create();
Assert.assertEquals(3, write.userdata().size());
Assert.assertEquals("one-to-many", write.userdata().get("multiplicity"));
Assert.assertEquals("picture2", write.userdata().get("icon"));
String time = (String) write.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
write = schema.edgeLabel("write").userdata("icon", "").eliminate();
Assert.assertEquals(2, write.userdata().size());
Assert.assertEquals("one-to-many", write.userdata().get("multiplicity"));
time = (String) write.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testListByNames.
@Test
public void testListByNames() {
SchemaManager schema = schema();
EdgeLabel father = schema.edgeLabel("father").link("person", "person").create();
EdgeLabel write = schema.edgeLabel("write").link("person", "book").create();
List<EdgeLabel> edgeLabels;
edgeLabels = schema.getEdgeLabels(ImmutableList.of("father"));
Assert.assertEquals(1, edgeLabels.size());
assertContains(edgeLabels, father);
edgeLabels = schema.getEdgeLabels(ImmutableList.of("write"));
Assert.assertEquals(1, edgeLabels.size());
assertContains(edgeLabels, write);
edgeLabels = schema.getEdgeLabels(ImmutableList.of("father", "write"));
Assert.assertEquals(2, edgeLabels.size());
assertContains(edgeLabels, father);
assertContains(edgeLabels, write);
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelTest method testResetEdgeLabelId.
@Test
public void testResetEdgeLabelId() {
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.id() > 0);
write.resetId();
Assert.assertEquals(0L, write.id());
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class PersonalRankApiTest method initPersonalRankGraph.
@BeforeClass
public static void initPersonalRankGraph() {
GraphManager graph = graph();
SchemaManager schema = schema();
schema.propertyKey("name").asText().ifNotExist().create();
schema.vertexLabel("person").properties("name").useCustomizeStringId().ifNotExist().create();
schema.vertexLabel("movie").properties("name").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("like").sourceLabel("person").targetLabel("movie").ifNotExist().create();
Vertex A = graph.addVertex(T.label, "person", T.id, "A", "name", "A");
Vertex B = graph.addVertex(T.label, "person", T.id, "B", "name", "B");
Vertex C = graph.addVertex(T.label, "person", T.id, "C", "name", "C");
Vertex a = graph.addVertex(T.label, "movie", T.id, "a", "name", "a");
Vertex b = graph.addVertex(T.label, "movie", T.id, "b", "name", "b");
Vertex c = graph.addVertex(T.label, "movie", T.id, "c", "name", "c");
Vertex d = graph.addVertex(T.label, "movie", T.id, "d", "name", "d");
A.addEdge("like", a);
A.addEdge("like", c);
B.addEdge("like", a);
B.addEdge("like", b);
B.addEdge("like", c);
B.addEdge("like", d);
C.addEdge("like", c);
C.addEdge("like", d);
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testAppendIndexLabelWithUserData.
@Test
public void testAppendIndexLabelWithUserData() {
SchemaManager schema = schema();
BaseFuncTest.initVertexLabel();
IndexLabel personByCity = schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create();
Assert.assertEquals(1, personByCity.userdata().size());
String time = (String) personByCity.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
personByCity = schema.indexLabel("personByCity").userdata("type", "secondary").append();
Assert.assertEquals(2, personByCity.userdata().size());
Assert.assertEquals("secondary", personByCity.userdata().get("type"));
time = (String) personByCity.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
Aggregations