コード例 #1
0
 @Test
 public void shouldGetGlobalBindings() throws Exception {
   final Bindings b = new SimpleBindings();
   final Object bound = new Object();
   b.put("x", bound);
   final GremlinExecutor gremlinExecutor = GremlinExecutor.build().globalBindings(b).create();
   assertEquals(bound, gremlinExecutor.getGlobalBindings().get("x"));
   gremlinExecutor.close();
 }
コード例 #2
0
  @Test
  public void shouldInitializeWithScriptAndMakeGlobalBinding() throws Exception {
    final GremlinExecutor gremlinExecutor =
        GremlinExecutor.build()
            .addEngineSettings(
                "gremlin-groovy",
                Collections.emptyList(),
                Collections.emptyList(),
                Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")),
                Collections.emptyMap())
            .create();

    assertEquals(2, gremlinExecutor.eval("add(1,1)").get());
    assertThat(gremlinExecutor.getGlobalBindings().keySet(), not(contains("someSet")));
    assertThat(gremlinExecutor.getGlobalBindings().keySet(), contains("name"));

    assertEquals("stephen", gremlinExecutor.getGlobalBindings().get("name"));

    gremlinExecutor.close();
  }