[7.x] Add supported-type tests to avg aggregation (#55283)

This commit is contained in:
Christos Soulios 2020-04-16 20:02:31 +03:00 committed by GitHub
parent 8b7bdae6cb
commit 5856344691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -52,7 +52,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;
@ -67,6 +69,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
public class AvgAggregatorTests extends AggregatorTestCase {
@ -709,4 +712,14 @@ public class AvgAggregatorTests extends AggregatorTestCase {
directory.close();
unmappedDirectory.close();
}
@Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
return singletonList(CoreValuesSourceType.NUMERIC);
}
@Override
protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldType, String fieldName) {
return new AvgAggregationBuilder("foo").field(fieldName);
}
}