package com.tinkerpop.gremlin.console.plugin;

import com.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.codehaus.groovy.tools.shell.Groovysh;
import org.codehaus.groovy.tools.shell.IO;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class SugarGremlinPluginTest {
    @Test
    public void shouldPluginSugar() throws Exception {
        final SugarGremlinPlugin plugin = new SugarGremlinPlugin();

        final Groovysh groovysh = new Groovysh();

        final Map<String,Object> env = new HashMap<>();
        env.put("ConsolePluginAcceptor.io", new IO());
        env.put("ConsolePluginAcceptor.shell", groovysh);

        final SpyPluginAcceptor spy = new SpyPluginAcceptor(groovysh::execute, () -> env);
        plugin.pluginTo(spy);

        groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic());
        assertEquals(6l, groovysh.execute("g.V().count().next()"));
        assertEquals(6l, groovysh.execute("g.V.count().next()"));
    }
}

@@ -73,43 +73,36 @@
 lin.
-tinkergraph.structure.TinkerFactory
+process.graph.GraphTraversal
 ;%0Aim
@@ -156,21 +156,23 @@
 e.Tinker
-Graph
+Factory
 ;%0Aimport
@@ -1065,32 +1065,50 @@
 assertEquals(6l,
+ ((GraphTraversal)
  groovysh.execut
@@ -1115,16 +1115,19 @@
 e(%22g.V()
+%22))
 .count()
@@ -1129,26 +1129,24 @@
 unt().next()
-%22)
 );%0A        a
@@ -1160,16 +1160,34 @@
 uals(6l,
+ ((GraphTraversal)
  groovys
@@ -1200,16 +1200,19 @@
 ute(%22g.V
+%22))
 .count()
@@ -1218,18 +1218,16 @@
 ).next()
-%22)
 );%0A    %7D

Make travis happy - maybe.