From ec76e7306e32ff9cba5a99bd2eed89b628290377 Mon Sep 17 00:00:00 2001 From: Andy Bristol Date: Wed, 1 Apr 2020 15:24:53 -0700 Subject: [PATCH] supported field type tests for max agg (#53701) Adds test hooks for testing supported ValuesSource types for the max aggregation --- .../aggregations/metrics/MaxAggregatorTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxAggregatorTests.java index 598d19795db..e37731388e4 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxAggregatorTests.java @@ -71,7 +71,9 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator; import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper; +import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValueType; +import org.elasticsearch.search.aggregations.support.ValuesSourceType; import org.elasticsearch.search.lookup.LeafDocLookup; import java.io.IOException; @@ -89,6 +91,7 @@ import java.util.function.Supplier; import static java.util.Collections.emptyList; import static java.util.Collections.singleton; +import static java.util.Collections.singletonList; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.hamcrest.Matchers.equalTo; @@ -158,6 +161,17 @@ public class MaxAggregatorTests extends AggregatorTestCase { return new ScriptService(Settings.EMPTY, engines, ScriptModule.CORE_CONTEXTS); } + @Override + protected List getSupportedValuesSourceTypes() { + return singletonList(CoreValuesSourceType.NUMERIC); + } + + @Override + protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) { + return new MaxAggregationBuilder("_name") + .field(fieldName); + } + public void testNoDocs() throws IOException { testCase(new MatchAllDocsQuery(), iw -> { // Intentionally not writing any docs