From a766d4aa06dae8b741679ee6aebec46231f841d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 12 Nov 2018 15:38:17 +0100 Subject: [PATCH] Correct implemented interface of ParsedReverseNested 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 --- .../aggregations/bucket/nested/ParsedReverseNested.java | 2 +- .../aggregations/bucket/nested/InternalNestedTests.java | 8 ++++++++ .../bucket/nested/InternalReverseNestedTests.java | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ParsedReverseNested.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ParsedReverseNested.java index dec15c3eded10..fafed73370c00 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ParsedReverseNested.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ParsedReverseNested.java @@ -23,7 +23,7 @@ import java.io.IOException; -public class ParsedReverseNested extends ParsedSingleBucketAggregation implements Nested { +public class ParsedReverseNested extends ParsedSingleBucketAggregation implements ReverseNested { @Override public String getType() { diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNestedTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNestedTests.java index a43e0dd519fab..039ef8fd12930 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNestedTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNestedTests.java @@ -22,9 +22,11 @@ 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 @@ protected Reader instanceReader() { protected Class implementationClass() { return ParsedNested.class; } + + @Override + protected void assertFromXContent(InternalNested aggregation, ParsedAggregation parsedAggregation) throws IOException { + super.assertFromXContent(aggregation, parsedAggregation); + assertTrue(parsedAggregation instanceof Nested); + } } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNestedTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNestedTests.java index ddfe10b27eb32..6031d435adc2b 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNestedTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNestedTests.java @@ -22,9 +22,11 @@ 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 @@ protected Reader instanceReader() { protected Class implementationClass() { return ParsedReverseNested.class; } + + @Override + protected void assertFromXContent(InternalReverseNested aggregation, ParsedAggregation parsedAggregation) throws IOException { + super.assertFromXContent(aggregation, parsedAggregation); + assertTrue(parsedAggregation instanceof ReverseNested); + } }