Small improvement in InternalAggregationTestCase test setup after changes in master (#24675)
This commit is contained in:
parent
42e8d4b761
commit
0b688a8733
|
@ -115,8 +115,6 @@ public class AggregationsTests extends ESTestCase {
|
||||||
aggsTests.add(new InternalMissingTests());
|
aggsTests.add(new InternalMissingTests());
|
||||||
aggsTests.add(new InternalNestedTests());
|
aggsTests.add(new InternalNestedTests());
|
||||||
aggsTests.add(new InternalReverseNestedTests());
|
aggsTests.add(new InternalReverseNestedTests());
|
||||||
// TODO can we find a way to include the children aggregation in this test?
|
|
||||||
//aggsTests.add(new InternalChildrenTests());
|
|
||||||
aggsTests.add(new InternalGlobalTests());
|
aggsTests.add(new InternalGlobalTests());
|
||||||
aggsTests.add(new InternalFilterTests());
|
aggsTests.add(new InternalFilterTests());
|
||||||
aggsTests.add(new InternalSamplerTests());
|
aggsTests.add(new InternalSamplerTests());
|
||||||
|
@ -129,7 +127,7 @@ public class AggregationsTests extends ESTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NamedXContentRegistry xContentRegistry() {
|
protected NamedXContentRegistry xContentRegistry() {
|
||||||
return new NamedXContentRegistry(InternalAggregationTestCase.getNamedXContents());
|
return new NamedXContentRegistry(InternalAggregationTestCase.getDefaultNamedXContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -147,9 +145,9 @@ public class AggregationsTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllAggsAreBeingTested() {
|
public void testAllAggsAreBeingTested() {
|
||||||
assertEquals(InternalAggregationTestCase.getNamedXContents().size(), aggsTests.size());
|
assertEquals(InternalAggregationTestCase.getDefaultNamedXContents().size(), aggsTests.size());
|
||||||
Set<String> aggs = aggsTests.stream().map((testCase) -> testCase.createTestInstance().getType()).collect(Collectors.toSet());
|
Set<String> aggs = aggsTests.stream().map((testCase) -> testCase.createTestInstance().getType()).collect(Collectors.toSet());
|
||||||
for (NamedXContentRegistry.Entry entry : InternalAggregationTestCase.getNamedXContents()) {
|
for (NamedXContentRegistry.Entry entry : InternalAggregationTestCase.getDefaultNamedXContents()) {
|
||||||
assertTrue(aggs.contains(entry.name.getPreferredName()));
|
assertTrue(aggs.contains(entry.name.getPreferredName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,22 +22,25 @@ package org.elasticsearch.join.aggregations;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.Writeable.Reader;
|
import org.elasticsearch.common.io.stream.Writeable.Reader;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry.Entry;
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregations;
|
import org.elasticsearch.search.aggregations.InternalAggregations;
|
||||||
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
|
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
|
||||||
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
|
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
|
||||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalChildrenTests extends InternalSingleBucketAggregationTestCase<InternalChildren> {
|
public class InternalChildrenTests extends InternalSingleBucketAggregationTestCase<InternalChildren> {
|
||||||
|
|
||||||
@BeforeClass
|
@Override
|
||||||
public static void init() {
|
protected List<NamedXContentRegistry.Entry> getNamedXContents() {
|
||||||
namedXContents.add(new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(ChildrenAggregationBuilder.NAME),
|
List<Entry> extendedNamedXContents = new ArrayList<>(super.getNamedXContents());
|
||||||
|
extendedNamedXContents.add(new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(ChildrenAggregationBuilder.NAME),
|
||||||
(p, c) -> ParsedChildren.fromXContent(p, (String) c)));
|
(p, c) -> ParsedChildren.fromXContent(p, (String) c)));
|
||||||
|
return extendedNamedXContents ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -130,7 +130,8 @@ public abstract class InternalAggregationTestCase<T extends InternalAggregation>
|
||||||
new SearchModule(Settings.EMPTY, false, emptyList()).getNamedWriteables());
|
new SearchModule(Settings.EMPTY, false, emptyList()).getNamedWriteables());
|
||||||
|
|
||||||
private final NamedXContentRegistry namedXContentRegistry = new NamedXContentRegistry(getNamedXContents());
|
private final NamedXContentRegistry namedXContentRegistry = new NamedXContentRegistry(getNamedXContents());
|
||||||
protected static final List<NamedXContentRegistry.Entry> namedXContents;
|
|
||||||
|
private static final List<NamedXContentRegistry.Entry> namedXContents;
|
||||||
static {
|
static {
|
||||||
Map<String, ContextParser<Object, ? extends Aggregation>> map = new HashMap<>();
|
Map<String, ContextParser<Object, ? extends Aggregation>> map = new HashMap<>();
|
||||||
map.put(CardinalityAggregationBuilder.NAME, (p, c) -> ParsedCardinality.fromXContent(p, (String) c));
|
map.put(CardinalityAggregationBuilder.NAME, (p, c) -> ParsedCardinality.fromXContent(p, (String) c));
|
||||||
|
@ -175,7 +176,11 @@ public abstract class InternalAggregationTestCase<T extends InternalAggregation>
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<NamedXContentRegistry.Entry> getNamedXContents() {
|
public static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
|
||||||
|
return namedXContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<NamedXContentRegistry.Entry> getNamedXContents() {
|
||||||
return namedXContents;
|
return namedXContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue