@Test
    public void shouldEvalGraph() throws Exception {
        final Graph graph = TinkerFactory.createModern();
        final GraphTraversalSource g = graph.traversal();
        GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
        Bindings bindings = engine.createBindings();
        bindings.put("graph", graph);
        bindings.put("marko", convertToVertexId(graph, "marko"));
        assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings));

        engine = new GremlinGroovyScriptEngine(notSandboxed);
        try {
            bindings = engine.createBindings();
            bindings.put("graph", graph);
            bindings.put("marko", convertToVertexId(graph, "marko"));
            assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings));
            fail("Type checking should have forced an error as 'graph' is not defined");
        } catch (Exception ex) {
            assertEquals(MultipleCompilationErrorsException.class, ex.getCause().getClass());
            assertThat(ex.getMessage(), containsString("The variable [graph] is undeclared."));
        }

        engine = new GremlinGroovyScriptEngine(notSandboxed);
        try {
            bindings = engine.createBindings();
            bindings.put("graph", graph);
            bindings.put("x", convertToVertexId(graph, "marko"));
            assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(x).next()", bindings));
            fail("Type checking should have forced an error as 'graph' is not defined");
        } catch (Exception ex) {
            assertEquals(MultipleCompilationErrorsException.class, ex.getCause().getClass());
            assertThat(ex.getMessage(), containsString("The variable [graph] is undeclared."));
        }

        engine = new GremlinGroovyScriptEngine(sandboxed);
        bindings = engine.createBindings();
        bindings.put("graph", graph);
        bindings.put("marko", convertToVertexId(graph, "marko"));
        assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings));

        engine = new GremlinGroovyScriptEngine(sandboxed);
        bindings = engine.createBindings();
        bindings.put("graph", graph);
        bindings.put("x", convertToVertexId(graph, "marko"));
        assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(x).next()", bindings));
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java