From 29263637c097476ef937aa917855de2389f2fc96 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 6 Apr 2016 16:36:19 -0400 Subject: [PATCH] React to registration changes in core Original commit: elastic/x-pack-elasticsearch@f5961dc410b23ae0fc5526f31c9251824b4f7e65 --- .../graph/action/GraphExploreRequest.java | 1 - .../watcher/support/WatcherUtilsTests.java | 21 ++++++++------- .../watcher/watch/WatchTests.java | 27 ++++++++++--------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java index 3ddf8072399..f39bfdda84b 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/GraphExploreRequest.java @@ -16,7 +16,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.aggregations.bucket.sampler.SamplerAggregatorBuilder; -import org.elasticsearch.search.aggregations.bucket.sampler.SamplerParser; import org.elasticsearch.search.aggregations.bucket.significant.SignificantTerms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherUtilsTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherUtilsTests.java index 0edd9216f13..101050f67ef 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherUtilsTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/WatcherUtilsTests.java @@ -6,6 +6,12 @@ package org.elasticsearch.watcher.support; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.support.IndicesOptions; @@ -20,9 +26,9 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.query.MatchAllQueryBuilder; -import org.elasticsearch.index.query.MatchAllQueryParser; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.index.query.QueryParser; import org.elasticsearch.indices.query.IndicesQueriesRegistry; import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.script.Template; @@ -33,13 +39,8 @@ import org.elasticsearch.watcher.support.clock.SystemClock; import org.elasticsearch.watcher.support.text.TextTemplate; import org.joda.time.DateTime; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - import static java.util.Collections.singletonMap; + import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.watcher.support.WatcherDateTimeUtils.formatDate; import static org.elasticsearch.watcher.support.WatcherUtils.DEFAULT_INDICES_OPTIONS; @@ -135,8 +136,9 @@ public class WatcherUtilsTests extends ESTestCase { builder = WatcherUtils.writeSearchRequest(expectedRequest, builder, ToXContent.EMPTY_PARAMS); XContentParser parser = XContentHelper.createParser(builder.bytes()); assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT)); + QueryParser termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, - singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryParser.QUERY_NAME_FIELD, new MatchAllQueryParser()))); + singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); QueryParseContext context = new QueryParseContext(registry); context.reset(parser); SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null); @@ -224,8 +226,9 @@ public class WatcherUtilsTests extends ESTestCase { XContentParser parser = XContentHelper.createParser(builder.bytes()); assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT)); + QueryParser termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, - singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryParser.QUERY_NAME_FIELD, new MatchAllQueryParser()))); + singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); QueryParseContext context = new QueryParseContext(registry); context.reset(parser); SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java index f78983e7e0f..53cf580b49f 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java @@ -5,6 +5,14 @@ */ package org.elasticsearch.watcher.watch; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.Tuple; @@ -15,7 +23,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.MatchAllQueryBuilder; -import org.elasticsearch.index.query.MatchAllQueryParser; +import org.elasticsearch.index.query.QueryParser; import org.elasticsearch.indices.query.IndicesQueriesRegistry; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.watcher.actions.ActionFactory; @@ -78,8 +86,8 @@ import org.elasticsearch.watcher.support.http.HttpMethod; import org.elasticsearch.watcher.support.http.HttpRequestTemplate; import org.elasticsearch.watcher.support.http.auth.HttpAuthRegistry; import org.elasticsearch.watcher.support.http.auth.basic.BasicAuthFactory; -import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy; import org.elasticsearch.watcher.support.init.proxy.ScriptServiceProxy; +import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy; import org.elasticsearch.watcher.support.secret.SecretService; import org.elasticsearch.watcher.support.text.TextTemplate; import org.elasticsearch.watcher.support.text.TextTemplateEngine; @@ -119,17 +127,10 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.Before; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import static java.util.Collections.singleton; import static java.util.Collections.singletonMap; import static java.util.Collections.unmodifiableMap; + import static org.elasticsearch.watcher.input.InputBuilders.searchInput; import static org.elasticsearch.watcher.test.WatcherTestUtils.matchAllRequest; import static org.elasticsearch.watcher.trigger.TriggerBuilders.schedule; @@ -352,8 +353,9 @@ public class WatchTests extends ESTestCase { Map parsers = new HashMap<>(); switch (input.type()) { case SearchInput.TYPE: + QueryParser termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap( - MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryParser.QUERY_NAME_FIELD, new MatchAllQueryParser()))); + MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, queryRegistry, null, null)); return new InputRegistry(parsers); default: @@ -419,8 +421,9 @@ public class WatchTests extends ESTestCase { } private TransformRegistry transformRegistry() { + QueryParser termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY, - singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryParser.QUERY_NAME_FIELD, new MatchAllQueryParser()))); + singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); Map factories = new HashMap<>(); ChainTransformFactory parser = new ChainTransformFactory(); factories.put(ChainTransform.TYPE, parser);