diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/WatcherConditionScript.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/WatcherConditionScript.java index 1148cc6a58eb5..2977a92bb5e41 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/WatcherConditionScript.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/condition/WatcherConditionScript.java @@ -18,30 +18,14 @@ * A script to determine whether a watch should be run. */ public abstract class WatcherConditionScript { - public static final String[] PARAMETERS = {}; - - private static final Map DEPRECATIONS; - - static { - Map deprecations = new HashMap<>(); - deprecations.put( - "ctx", - "Accessing variable [ctx] via [params.ctx] from within a watcher_condition script " + - "is deprecated in favor of directly accessing [ctx]." - ); - DEPRECATIONS = Collections.unmodifiableMap(deprecations); - } private final Map params; // TODO: ctx should have its members extracted into execute parameters, but it needs to be a member for bwc access in params private final Map ctx; public WatcherConditionScript(Map params, WatchExecutionContext watcherContext) { - Map paramsWithCtx = new HashMap<>(params); - Map ctx = Variables.createCtx(watcherContext, watcherContext.payload()); - paramsWithCtx.put("ctx", ctx); - this.params = new ParameterMap(Collections.unmodifiableMap(paramsWithCtx), DEPRECATIONS); - this.ctx = ctx; + this.params = params; + this.ctx = Variables.createCtx(watcherContext, watcherContext.payload());; } public abstract boolean execute(); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/WatcherTransformScript.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/WatcherTransformScript.java index 6d84c32578bc0..27aec14f70c30 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/WatcherTransformScript.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/script/WatcherTransformScript.java @@ -19,30 +19,14 @@ * A script to transform the results of a watch execution. */ public abstract class WatcherTransformScript { - public static final String[] PARAMETERS = {}; - - private static final Map DEPRECATIONS; - - static { - Map deprecations = new HashMap<>(); - deprecations.put( - "ctx", - "Accessing variable [ctx] via [params.ctx] from within a watcher_transform script " + - "is deprecated in favor of directly accessing [ctx]." - ); - DEPRECATIONS = Collections.unmodifiableMap(deprecations); - } private final Map params; // TODO: ctx should have its members extracted into execute parameters, but it needs to be a member bwc access in params private final Map ctx; public WatcherTransformScript(Map params, WatchExecutionContext watcherContext, Payload payload) { - Map paramsWithCtx = new HashMap<>(params); - Map ctx = Variables.createCtx(watcherContext, payload); - paramsWithCtx.put("ctx", ctx); - this.params = new ParameterMap(Collections.unmodifiableMap(paramsWithCtx), DEPRECATIONS); - this.ctx = ctx; + this.params = params; + this.ctx = Variables.createCtx(watcherContext, payload); } public abstract Object execute(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java index 1787904e98f0a..40a7d053e943f 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java @@ -206,7 +206,7 @@ public void testScriptConditionAccessCtx() throws Exception { assertThat(condition.execute(ctx).met(), is(true)); } - public void testParamsCtxDeprecated() throws Exception { + public void testParamsCtxNull() throws Exception { WatchExecutionContext watcherContext = mock(WatchExecutionContext.class); when(watcherContext.id()).thenReturn(mock(Wid.class)); when(watcherContext.watch()).thenReturn(mock(Watch.class)); @@ -216,13 +216,11 @@ public void testParamsCtxDeprecated() throws Exception { WatcherConditionScript watcherScript = new WatcherConditionScript(Collections.emptyMap(), watcherContext) { @Override public boolean execute() { - assertThat(getParams().get("ctx"), is(getCtx())); + assertNull(getParams().get("ctx")); return true; } }; - watcherScript.execute(); - assertWarnings("Accessing variable [ctx] via [params.ctx] from within a watcher_condition script " + - "is deprecated in favor of directly accessing [ctx]."); + assertTrue(watcherScript.execute()); } private static XContentBuilder createConditionContent(String script, String scriptLang, ScriptType scriptType) throws IOException { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java index 077e168c547ee..1b04868faf10d 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java @@ -202,9 +202,7 @@ public Object execute() { return getParams().get("ctx"); } }; - assertThat(watcherScript.execute(), is(watcherScript.getCtx())); - assertWarnings("Accessing variable [ctx] via [params.ctx] from within a watcher_transform script " + - "is deprecated in favor of directly accessing [ctx]."); + assertNull(watcherScript.execute()); } static String scriptTypeField(ScriptType type) {