From 4ecd1e5d50916bee34fcb89056f0e67ad378df10 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 26 May 2017 00:33:38 -0700 Subject: [PATCH] Fix mock painless to use mock compiled script for generating search/executable scripts Original commit: elastic/x-pack-elasticsearch@362432664b4863bc2e4bcb6d40242087ba1132c2 --- .../xpack/monitoring/test/MockPainlessScriptEngine.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java index 5ff59ac30ae..627498400a4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java @@ -43,11 +43,12 @@ public class MockPainlessScriptEngine extends MockScriptEngine { } @Override - public T compile(String name, String script, ScriptContext context, Map params) { + public T compile(String name, String script, ScriptContext context, Map options) { + MockCompiledScript compiledScript = new MockCompiledScript(name, options, script, p -> script); if (context.instanceClazz.equals(ExecutableScript.class)) { - return context.factoryClazz.cast((ExecutableScript.Factory) vars -> new MockExecutableScript(vars, p -> script)); + return context.factoryClazz.cast((ExecutableScript.Factory) compiledScript::createExecutableScript); } else if (context.instanceClazz.equals(SearchScript.class)) { - return context.factoryClazz.cast((SearchScript.Factory) (vars, lookup) -> new MockSearchScript(lookup, vars, p -> script)); + return context.factoryClazz.cast((SearchScript.Factory) compiledScript::createSearchScript); } throw new IllegalArgumentException("mock painless does not know how to handle context [" + context.name + "]"); }