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 + "]"); }