use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.
the class GremlinApiTest method testPrimitiveObject.
@Test
public void testPrimitiveObject() {
GremlinRequest request = new GremlinRequest("1 + 2");
ResultSet resultSet = gremlin().execute(request);
Assert.assertEquals(1, resultSet.size());
Iterator<Result> results = resultSet.iterator();
while (results.hasNext()) {
Result result = results.next();
Object object = result.getObject();
Assert.assertEquals(Integer.class, object.getClass());
Assert.assertEquals(3, object);
}
}
use of com.baidu.hugegraph.api.gremlin.GremlinRequest in project incubator-hugegraph-toolchain by apache.
the class GremlinApiTest method testAttachedManager.
@Test
public void testAttachedManager() {
GremlinRequest request = new GremlinRequest("g.V()");
ResultSet resultSet = gremlin().execute(request);
Assert.assertEquals(6, resultSet.size());
Iterator<Result> results = resultSet.iterator();
while (results.hasNext()) {
Result result = results.next();
Object object = result.getObject();
Assert.assertEquals(Vertex.class, object.getClass());
Vertex vertex = (Vertex) object;
Assert.assertNotNull(Whitebox.getInternalState(vertex, "manager"));
}
request = new GremlinRequest("g.E()");
resultSet = gremlin().execute(request);
Assert.assertEquals(6, resultSet.size());
results = resultSet.iterator();
while (results.hasNext()) {
Result result = results.next();
Object object = result.getObject();
Assert.assertEquals(Edge.class, object.getClass());
Edge edge = (Edge) object;
Assert.assertNotNull(Whitebox.getInternalState(edge, "manager"));
}
request = new GremlinRequest("g.V().outE().path()");
resultSet = gremlin().execute(request);
Assert.assertEquals(6, resultSet.size());
results = resultSet.iterator();
while (results.hasNext()) {
Result result = results.next();
Object object = result.getObject();
Assert.assertEquals(Path.class, object.getClass());
Path path = (Path) object;
Assert.assertNotNull(path.objects());
for (Object pathObject : path.objects()) {
Assert.assertTrue(pathObject instanceof GraphAttachable);
Assert.assertNotNull(Whitebox.getInternalState(pathObject, "manager"));
}
Assert.assertNull(path.crosspoint());
}
}
Aggregations