Package org.elasticsearch.script
Class MockScriptEngine
java.lang.Object
org.elasticsearch.script.MockScriptEngine
- All Implemented Interfaces:
Closeable,AutoCloseable,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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA non-typed compiler for a single custom contextclassstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classclassclassclass -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMockScriptEngine(String type, Map<String, Function<Map<String, Object>, Object>> deterministicScripts, Map<String, Function<Map<String, Object>, Object>> nonDeterministicScripts, Map<ScriptContext<?>, MockScriptEngine.ContextCompiler> contexts) MockScriptEngine(String type, Map<String, Function<Map<String, Object>, Object>> scripts, Map<ScriptContext<?>, MockScriptEngine.ContextCompiler> contexts) -
Method Summary
Modifier and TypeMethodDescription<T> TSet<ScriptContext<?>>getType()static ScriptmockInlineScript(String script) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.script.ScriptEngine
close
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
MockScriptEngine
-
MockScriptEngine
-
MockScriptEngine
public MockScriptEngine()
-
-
Method Details
-
getType
- Specified by:
getTypein interfaceScriptEngine
-
compile
public <T> T compile(String name, String source, ScriptContext<T> context, Map<String, String> params) - Specified by:
compilein interfaceScriptEngine
-
getSupportedContexts
- Specified by:
getSupportedContextsin interfaceScriptEngine
-
mockInlineScript
-