GroovyCompilerGremlinPlugin extends AbstractGremlinPlugin { public static Builder build() { return new Builder(); } private  GroovyCompilerGremlinPlugin(final Builder builder); static Builder build();  }
@Test public void shouldConfigureForGroovyOnly() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). compilation(GroovyCompilerGremlinPlugin.Compilation.COMPILE_STATIC).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-not-real"); assertThat(customizers.isPresent(), is(false)); }
@Test public void shouldConfigureWithCompileStatic() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). compilation(GroovyCompilerGremlinPlugin.Compilation.COMPILE_STATIC).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof CompileStaticGroovyCustomizer).count()); }
@Test public void shouldConfigureWithTypeChecked() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). compilation(GroovyCompilerGremlinPlugin.Compilation.TYPE_CHECKED).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof TypeCheckedGroovyCustomizer).count()); }
@Test public void shouldConfigureWithCustomCompilerConfigurations() { final Map<String,Object> conf = new HashMap<>(); conf.put("Debug", true); final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). compilerConfigurationOptions(conf).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof ConfigurationGroovyCustomizer).count()); final CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); assertThat(compilerConfiguration.getDebug(), is(false)); final ConfigurationGroovyCustomizer provider = (ConfigurationGroovyCustomizer) customizers.get()[0]; provider.applyCustomization(compilerConfiguration); assertThat(compilerConfiguration.getDebug(), is(true)); }
@Test public void shouldConfigureWithInterpreterMode() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). enableInterpreterMode(true).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof InterpreterModeGroovyCustomizer).count()); }
@Test public void shouldConfigureWithThreadInterrupt() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). enableThreadInterrupt(true).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof ThreadInterruptGroovyCustomizer).count()); }
@Test public void shouldConfigureWithTimedInterrupt() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). timedInterrupt(60000).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, Stream.of(customizers.get()).filter(c -> c instanceof TimedInterruptGroovyCustomizer).count()); }
@Test public void shouldConfigureWithCompilationOptions() { final GroovyCompilerGremlinPlugin plugin = GroovyCompilerGremlinPlugin.build(). classMapCacheSpecification("initialCapacity=1000,maximumSize=1000"). expectedCompilationTime(30000).create(); final Optional<Customizer[]> customizers = plugin.getCustomizers("gremlin-groovy"); assertThat(customizers.isPresent(), is(true)); assertEquals(1, customizers.get().length); assertThat(customizers.get()[0], instanceOf(CompilationOptionsCustomizer.class)); assertEquals(30000, ((CompilationOptionsCustomizer) customizers.get()[0]).getExpectedCompilationTime()); assertEquals("initialCapacity=1000,maximumSize=1000", ((CompilationOptionsCustomizer) customizers.get()[0]).getClassMapCacheSpecification()); }