Search in sources :

Example 36 with Vertex

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);
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) Test(org.junit.Test)

Example 37 with Vertex

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"));
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test)

Example 38 with Vertex

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);
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) LoadOptions(com.baidu.hugegraph.loader.executor.LoadOptions) Test(org.junit.Test)

Example 39 with Vertex

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"));
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test)

Example 40 with Vertex

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"));
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test)

Aggregations

Vertex (com.baidu.hugegraph.structure.graph.Vertex)165 Test (org.junit.Test)110 Edge (com.baidu.hugegraph.structure.graph.Edge)33 HugeClient (com.baidu.hugegraph.driver.HugeClient)22 ArrayList (java.util.ArrayList)21 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)18 BaseClientTest (com.baidu.hugegraph.BaseClientTest)17 BeforeClass (org.junit.BeforeClass)17 GraphManager (com.baidu.hugegraph.driver.GraphManager)14 BatchVertexRequest (com.baidu.hugegraph.structure.graph.BatchVertexRequest)13 Path (com.baidu.hugegraph.structure.graph.Path)11 Result (com.baidu.hugegraph.structure.gremlin.Result)10 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)10 List (java.util.List)10 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)9 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 Map (java.util.Map)6 RestResult (com.baidu.hugegraph.rest.RestResult)5 PathsWithVertices (com.baidu.hugegraph.structure.traverser.PathsWithVertices)5