Class MockScriptEngine

java.lang.Object
org.elasticsearch.script.MockScriptEngine
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, org.elasticsearch.script.ScriptEngine

public class MockScriptEngine
extends java.lang.Object
implements org.elasticsearch.script.ScriptEngine
A mocked script engine that can be used for testing purpose. This script engine allows to define a set of predefined scripts that basically a combination of a key and a function: The key can be anything as long as it is a String and is used to resolve the scripts at compilation time. For inline scripts, the key can be a description of the script. For stored and file scripts, the source must match a key in the predefined set of scripts. The function is used to provide the result of the script execution and can return anything.
  • Field Details

  • Constructor Details

    • MockScriptEngine

      public MockScriptEngine​(java.lang.String type, java.util.Map<java.lang.String,​java.util.function.Function<java.util.Map<java.lang.String,​java.lang.Object>,​java.lang.Object>> scripts, java.util.Map<org.elasticsearch.script.ScriptContext<?>,​MockScriptEngine.ContextCompiler> contexts)
    • MockScriptEngine

      public MockScriptEngine​(java.lang.String type, java.util.Map<java.lang.String,​java.util.function.Function<java.util.Map<java.lang.String,​java.lang.Object>,​java.lang.Object>> deterministicScripts, java.util.Map<java.lang.String,​java.util.function.Function<java.util.Map<java.lang.String,​java.lang.Object>,​java.lang.Object>> nonDeterministicScripts, java.util.Map<org.elasticsearch.script.ScriptContext<?>,​MockScriptEngine.ContextCompiler> contexts)
    • MockScriptEngine

      public MockScriptEngine()
  • Method Details

    • getType

      public java.lang.String getType()
      Specified by:
      getType in interface org.elasticsearch.script.ScriptEngine
    • compile

      public <T> T compile​(java.lang.String name, java.lang.String source, org.elasticsearch.script.ScriptContext<T> context, java.util.Map<java.lang.String,​java.lang.String> params)
      Specified by:
      compile in interface org.elasticsearch.script.ScriptEngine
    • getSupportedContexts

      public java.util.Set<org.elasticsearch.script.ScriptContext<?>> getSupportedContexts()
      Specified by:
      getSupportedContexts in interface org.elasticsearch.script.ScriptEngine
    • mockInlineScript

      public static org.elasticsearch.script.Script mockInlineScript​(java.lang.String script)