Search in sources :

Example 1 with GremlinRequest

use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.

the class GremlinApiTest method testQueryAllEdges.

@Test
public void testQueryAllEdges() {
    GremlinRequest request = new GremlinRequest("g.E()");
    ResultSet resultSet = gremlin().execute(request);
    Assert.assertEquals(6, resultSet.size());
    request = new GremlinRequest("g.E().drop()");
    gremlin().execute(request);
    request = new GremlinRequest("g.E()");
    resultSet = gremlin().execute(request);
    Assert.assertEquals(0, resultSet.size());
}
Also used : ResultSet(com.baidu.hugegraph.structure.gremlin.ResultSet) GremlinRequest(com.baidu.hugegraph.api.gremlin.GremlinRequest) Test(org.junit.Test)

Example 2 with GremlinRequest

use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.

the class GremlinApiTest method testIterateEmptyResultSet.

@Test
public void testIterateEmptyResultSet() {
    GremlinRequest request = new GremlinRequest("g.V().limit(0)");
    ResultSet resultSet = gremlin().execute(request);
    Assert.assertEquals(0, resultSet.size());
    Assert.assertThrows(NoSuchElementException.class, () -> {
        resultSet.iterator().next();
    });
}
Also used : ResultSet(com.baidu.hugegraph.structure.gremlin.ResultSet) GremlinRequest(com.baidu.hugegraph.api.gremlin.GremlinRequest) Test(org.junit.Test)

Example 3 with GremlinRequest

use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.

the class GremlinApiTest method testQueryAllVertices.

@Test
public void testQueryAllVertices() {
    GremlinRequest request = new GremlinRequest("g.V()");
    ResultSet resultSet = gremlin().execute(request);
    Assert.assertEquals(6, resultSet.size());
    request = new GremlinRequest("g.V().drop()");
    gremlin().execute(request);
    request = new GremlinRequest("g.V()");
    resultSet = gremlin().execute(request);
    Assert.assertEquals(0, resultSet.size());
}
Also used : ResultSet(com.baidu.hugegraph.structure.gremlin.ResultSet) GremlinRequest(com.baidu.hugegraph.api.gremlin.GremlinRequest) Test(org.junit.Test)

Example 4 with GremlinRequest

use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.

the class GremlinApiTest method testSecurityOperation.

@Test
public void testSecurityOperation() {
    GremlinRequest request = new GremlinRequest("System.exit(-1)");
    Assert.assertThrows(ServerException.class, () -> {
        gremlin().execute(request);
    }, e -> {
        String msg = "Not allowed to call System.exit() via Gremlin";
        Assert.assertContains(msg, e.getMessage());
    });
}
Also used : GremlinRequest(com.baidu.hugegraph.api.gremlin.GremlinRequest) Test(org.junit.Test)

Example 5 with GremlinRequest

use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.

the class GremlinApiTest method testInvalidGremlin.

@Test
public void testInvalidGremlin() {
    Assert.assertThrows(ServerException.class, () -> {
        client().post("gremlin", "{");
    }, e -> {
        Assert.assertContains("body could not be parsed", e.getMessage());
    });
    GremlinRequest request = new GremlinRequest("g.V2()");
    Assert.assertThrows(ServerException.class, () -> {
        gremlin().execute(request);
    }, e -> {
        Assert.assertContains("No signature of method: ", e.getMessage());
        Assert.assertContains(".V2() is applicable for argument types: ()", e.getMessage());
    });
}
Also used : GremlinRequest(com.baidu.hugegraph.api.gremlin.GremlinRequest) Test(org.junit.Test)

Aggregations

GremlinRequest (com.baidu.hugegraph.api.gremlin.GremlinRequest)12 Test (org.junit.Test)11 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)9 Vertex (com.baidu.hugegraph.structure.graph.Vertex)2 Result (com.baidu.hugegraph.structure.gremlin.Result)2 HugeClient (com.baidu.hugegraph.driver.HugeClient)1 Task (com.baidu.hugegraph.structure.Task)1 GraphAttachable (com.baidu.hugegraph.structure.constant.GraphAttachable)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 Path (com.baidu.hugegraph.structure.graph.Path)1 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)1