use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testHttpsClientValueMapping.
@Test
public void testHttpsClientValueMapping() {
ioUtil.write("vertex_person.csv", "tiny,1,1,1", "mary,2,2,2");
String[] args = new String[] { "-f", structPath("value_mapping/struct.json"), "-s", configPath("value_mapping/schema.groovy"), "-g", GRAPH, "-h", SERVER, "-p", String.valueOf(HTTPS_PORT), "--protocol", HTTPS_PROTOCOL, "--trust-store-file", TRUST_STORE_FILE, "--trust-store-password", "hugegraph", "--batch-insert-threads", "2", "--test-mode", "true" };
HugeGraphLoader.main(args);
HugeClient httpsClient = null;
try {
httpsClient = HugeClient.builder(HTTPS_URL, GRAPH).configSSL(TRUST_STORE_FILE, "hugegraph").build();
List<Vertex> vertices = httpsClient.graph().listVertices();
Assert.assertEquals(2, vertices.size());
} finally {
clearAndClose(httpsClient, GRAPH);
}
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testSelectedFields.
@Test
public void testSelectedFields() {
ioUtil.write("vertex_person.csv", "name,age,city,redundant", "marko,29,Beijing,value1", "vadas,27,Hongkong,value2");
String[] args = new String[] { "-f", structPath("selected_fields/struct.json"), "-s", configPath("selected_fields/schema.groovy"), "-g", GRAPH, "-h", SERVER, "--test-mode", "true" };
HugeGraphLoader.main(args);
List<Vertex> vertices = CLIENT.graph().listVertices();
Assert.assertEquals(2, vertices.size());
for (Vertex vertex : vertices) {
Assert.assertEquals(3, vertex.properties().size());
Assert.assertFalse(vertex.properties().containsKey("redundant"));
}
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testHttpsHolderClientValueMapping.
@Test
public void testHttpsHolderClientValueMapping() {
ioUtil.write("vertex_person.csv", "marko,1,1,1", "vadas,2,2,2");
String[] args = new String[] { "-f", structPath("value_mapping/struct.json"), "-s", configPath("value_mapping/schema.groovy"), "-g", GRAPH, "-h", SERVER, "-p", String.valueOf(HTTPS_PORT), "--protocol", HTTPS_PROTOCOL, "--trust-store-file", TRUST_STORE_FILE, "--trust-store-password", "hugegraph", "--batch-insert-threads", "2", "--test-mode", "true" };
HugeGraphLoader.main(args);
LoadOptions options = new LoadOptions();
options.host = SERVER;
options.port = HTTPS_PORT;
options.graph = GRAPH;
options.protocol = HTTPS_PROTOCOL;
options.trustStoreFile = TRUST_STORE_FILE;
options.trustStoreToken = "hugegraph";
HugeClient httpsClient = null;
try {
httpsClient = HugeClientHolder.create(options);
List<Vertex> vertices = httpsClient.graph().listVertices();
Assert.assertEquals(2, vertices.size());
} finally {
clearAndClose(httpsClient, GRAPH);
}
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testVertexJointPrimaryKeys.
@Test
public void testVertexJointPrimaryKeys() {
ioUtil.write("vertex_person.csv", "name,age,city", "marko,29,Beijing");
String[] args = new String[] { "-f", structPath("vertex_joint_pks/struct.json"), "-s", configPath("vertex_joint_pks/schema.groovy"), "-g", GRAPH, "-h", SERVER, "--test-mode", "true" };
HugeGraphLoader.main(args);
List<Vertex> vertices = CLIENT.graph().listVertices();
Assert.assertEquals(1, vertices.size());
Vertex vertex = vertices.get(0);
Assert.assertTrue(vertex.id().toString().contains("marko!Beijing"));
Assert.assertEquals("person", vertex.label());
Assert.assertEquals("marko", vertex.property("name"));
Assert.assertEquals(29, vertex.property("age"));
Assert.assertEquals("Beijing", vertex.property("city"));
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class FileLoadTest method testValueMapping.
@Test
public void testValueMapping() throws java.text.ParseException {
/*
* "age": {"1": 25, "2": 30}
* "birth": {"1": "1994-01-01", "2": "1989-01-01"}
* "city": "1": "Beijing", "2": "Shanghai"
*/
ioUtil.write("vertex_person.csv", "marko,1,1,1", "vadas,2,2,2");
String[] args = new String[] { "-f", structPath("value_mapping/struct.json"), "-s", configPath("value_mapping/schema.groovy"), "-g", GRAPH, "-h", SERVER, "--test-mode", "true" };
HugeGraphLoader.main(args);
List<Vertex> vertices = CLIENT.graph().listVertices();
Assert.assertEquals(2, vertices.size());
Vertex marko, vadas;
if (vertices.get(0).property("name").equals("marko")) {
marko = vertices.get(0);
vadas = vertices.get(1);
} else {
vadas = vertices.get(0);
marko = vertices.get(1);
}
Assert.assertEquals(25, marko.property("age"));
Assert.assertEquals("Beijing", marko.property("city"));
assertDateEquals("1994-01-01 00:00:00.000", marko.property("birth"));
Assert.assertEquals(30, vadas.property("age"));
Assert.assertEquals("Shanghai", vadas.property("city"));
assertDateEquals("1989-01-01 00:00:00.000", vadas.property("birth"));
}
Aggregations