diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java index 0af4b38f4c3..a75061bf2c1 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java @@ -51,53 +51,4 @@ public class WatcherSearchTemplateRequestTests extends ESTestCase { fail("Failed to parse watch search request: " + e.getMessage()); } } - - public void testUpgradeSearchSource() throws IOException { - XContentBuilder contentBuilder = jsonBuilder(); - contentBuilder.startObject(); - contentBuilder.startObject("body"); - - contentBuilder.startObject("query"); - contentBuilder.startObject("script"); - contentBuilder.startObject("script"); - contentBuilder.field("inline", "return true"); - contentBuilder.endObject(); - contentBuilder.endObject(); - contentBuilder.endObject(); - - contentBuilder.startObject("aggregations"); - contentBuilder.startObject("avg_grade"); - contentBuilder.startObject("avg"); - contentBuilder.startObject("script"); - contentBuilder.field("inline", "1 + 1"); - contentBuilder.endObject(); - contentBuilder.endObject(); - contentBuilder.endObject(); - contentBuilder.startObject("another_avg"); - contentBuilder.startObject("avg"); - contentBuilder.startObject("script"); - contentBuilder.field("inline", "1 + 2"); - contentBuilder.field("lang", "javascript"); - contentBuilder.endObject(); - contentBuilder.endObject(); - contentBuilder.endObject(); - contentBuilder.endObject(); - - contentBuilder.endObject(); - contentBuilder.endObject(); - XContentParser parser = XContentHelper.createParser(contentBuilder.bytes()); - parser.nextToken(); - - SearchRequestParsers searchRequestParsers = new SearchModule(Settings.EMPTY, false, Collections.emptyList()) - .getSearchRequestParsers(); - WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent( - logger, parser, SearchType.DEFAULT, ParseFieldMatcher.STRICT, searchRequestParsers); - Map parsedResult = XContentHelper.convertToMap(result.getSearchSource(), true).v2(); - // after upgrading the language must be equal to legacy language, because no language was defined explicitly in these scripts: - assertThat(XContentMapValues.extractValue("query.script.script.lang", parsedResult), equalTo("your_legacy_lang")); - assertThat(XContentMapValues.extractValue("aggregations.avg_grade.avg.script.lang", parsedResult), equalTo("your_legacy_lang")); - // after upgrading the language must remain javascript here, because that has been explicitly defined in the script: - assertThat(XContentMapValues.extractValue("aggregations.another_avg.avg.script.lang", parsedResult), equalTo("javascript")); - } - }