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());
}
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();
});
}
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());
}
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());
});
}
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());
});
}
Aggregations