Correct implemented interface of ParsedReverseNested (#35455)

The ParsedReverseNested implementation should implement the ReverseNested
interface and not the Nested interface. Although this is an empty marker
interface it is confusing and can lead to casting errors. Also adding a test to
check that both ParsedNested and ParsedReverseNested implement the correct
interface.

Closes #35449
This commit is contained in:
Christoph Büscher 2018-11-13 10:34:29 +01:00 committed by GitHub
parent 09965cb370
commit 0a6614a03a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -23,7 +23,7 @@ import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregatio
import java.io.IOException;
public class ParsedReverseNested extends ParsedSingleBucketAggregation implements Nested {
public class ParsedReverseNested extends ParsedSingleBucketAggregation implements ReverseNested {
@Override
public String getType() {

View File

@ -22,9 +22,11 @@ package org.elasticsearch.search.aggregations.bucket.nested;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
import org.elasticsearch.search.aggregations.ParsedAggregation;
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -49,4 +51,10 @@ public class InternalNestedTests extends InternalSingleBucketAggregationTestCase
protected Class<? extends ParsedSingleBucketAggregation> implementationClass() {
return ParsedNested.class;
}
@Override
protected void assertFromXContent(InternalNested aggregation, ParsedAggregation parsedAggregation) throws IOException {
super.assertFromXContent(aggregation, parsedAggregation);
assertTrue(parsedAggregation instanceof Nested);
}
}

View File

@ -22,9 +22,11 @@ package org.elasticsearch.search.aggregations.bucket.nested;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.aggregations.InternalSingleBucketAggregationTestCase;
import org.elasticsearch.search.aggregations.ParsedAggregation;
import org.elasticsearch.search.aggregations.bucket.ParsedSingleBucketAggregation;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -49,4 +51,10 @@ public class InternalReverseNestedTests extends InternalSingleBucketAggregationT
protected Class<? extends ParsedSingleBucketAggregation> implementationClass() {
return ParsedReverseNested.class;
}
@Override
protected void assertFromXContent(InternalReverseNested aggregation, ParsedAggregation parsedAggregation) throws IOException {
super.assertFromXContent(aggregation, parsedAggregation);
assertTrue(parsedAggregation instanceof ReverseNested);
}
}