diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/ParsedCardinality.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/ParsedCardinality.java index 82104fc9db6..5a615f61a4a 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/ParsedCardinality.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/ParsedCardinality.java @@ -22,7 +22,6 @@ package org.elasticsearch.search.aggregations.metrics.cardinality; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.ParsedAggregation; import java.io.IOException; @@ -33,10 +32,7 @@ public class ParsedCardinality extends ParsedAggregation implements Cardinality @Override public String getValueAsString() { - // InternalCardinality doesn't print "value_as_string", but you can get a formatted value using - // getValueAsString(). That method uses the raw formatter so we also use it here. - //norelease is it worth doing Double.toString(value) and removing the dependency to DocValueFormat.RAW ? - return DocValueFormat.RAW.format((double) cardinalityValue); + return Double.toString((double) cardinalityValue); } @Override diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/adjacency/InternalAdjacencyMatrixTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/adjacency/InternalAdjacencyMatrixTests.java index 58c3cc8a22c..a278f644735 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/adjacency/InternalAdjacencyMatrixTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/adjacency/InternalAdjacencyMatrixTests.java @@ -24,7 +24,6 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregationTestCase; import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.ArrayList; import java.util.List; @@ -36,7 +35,6 @@ public class InternalAdjacencyMatrixTests extends InternalMultiBucketAggregation private List keys; @Override - @Before public void setUp() throws Exception { super.setUp(); keys = new ArrayList<>(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFiltersTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFiltersTests.java index 03b5cb13d9c..ec1b71419ed 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFiltersTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFiltersTests.java @@ -24,7 +24,6 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregationTestCase; import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.ArrayList; import java.util.List; @@ -37,7 +36,6 @@ public class InternalFiltersTests extends InternalMultiBucketAggregationTestCase private List keys; @Override - @Before public void setUp() throws Exception { super.setUp(); keyed = randomBoolean(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/InternalRangeTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/InternalRangeTestCase.java index 38cdb003178..0482ab936b2 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/InternalRangeTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/InternalRangeTestCase.java @@ -26,7 +26,6 @@ import org.elasticsearch.search.aggregations.InternalMultiBucketAggregationTestC import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.List; import java.util.Map; @@ -37,7 +36,6 @@ public abstract class InternalRangeTestCase { private List> ranges; @Override - @Before public void setUp() throws Exception { super.setUp(); format = randomNumericDocValueFormat(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRangeTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRangeTests.java index f8cb8b3a1d8..3ba8fad4176 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRangeTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRangeTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.range.InternalRangeTestCase; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.junit.Before; import java.util.ArrayList; import java.util.Collections; @@ -43,7 +42,6 @@ public class InternalDateRangeTests extends InternalRangeTestCase> dateRanges; @Override - @Before public void setUp() throws Exception { super.setUp(); format = randomNumericDocValueFormat(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistanceTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistanceTests.java index e726530f79f..0adc5d028e5 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistanceTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistanceTests.java @@ -26,7 +26,6 @@ import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.range.InternalRangeTestCase; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.ArrayList; import java.util.Collections; @@ -38,7 +37,6 @@ public class InternalGeoDistanceTests extends InternalRangeTestCase> geoDistanceRanges; @Override - @Before public void setUp() throws Exception { super.setUp(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsTests.java index 5b0e715c8a6..793c6aec5c3 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.search.aggregations.bucket.significant.heuristics.JLHSc import org.elasticsearch.search.aggregations.bucket.significant.heuristics.MutualInformation; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.ArrayList; import java.util.HashSet; @@ -43,7 +42,6 @@ public class SignificantLongTermsTests extends InternalSignificantTermsTestCase private DocValueFormat format; @Override - @Before public void setUp() throws Exception { super.setUp(); significanceHeuristic = randomSignificanceHeuristic(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java index 07fe4c1ae82..762472e4be5 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsTests.java @@ -30,7 +30,6 @@ import org.elasticsearch.search.aggregations.bucket.significant.heuristics.JLHSc import org.elasticsearch.search.aggregations.bucket.significant.heuristics.MutualInformation; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.junit.Before; import java.util.ArrayList; import java.util.HashSet; @@ -43,7 +42,6 @@ public class SignificantStringTermsTests extends InternalSignificantTermsTestCas private SignificanceHeuristic significanceHeuristic; @Override - @Before public void setUp() throws Exception { super.setUp(); significanceHeuristic = randomSignificanceHeuristic(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalExtendedStatsTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalExtendedStatsTests.java index 8e90b881767..921a458b5ea 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalExtendedStatsTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/InternalExtendedStatsTests.java @@ -27,16 +27,16 @@ import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExte import org.elasticsearch.search.aggregations.metrics.stats.extended.ParsedExtendedStats; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.test.InternalAggregationTestCase; -import org.junit.Before; import java.util.List; import java.util.Map; public class InternalExtendedStatsTests extends InternalAggregationTestCase { - protected double sigma; - @Before - public void randomSigma() { + private double sigma; + + @Override + public void setUp() throws Exception { this.sigma = randomDoubleBetween(0, 10, true); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java index 56b521fdf79..1eefe6f6c2b 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java @@ -297,18 +297,11 @@ public abstract class InternalAggregationTestCase public final void testFromXContent() throws IOException { final T aggregation = createTestInstance(); - - //norelease Remove this assumption when all aggregations can be parsed back. - assumeTrue("This test does not support the aggregation type yet", - getNamedXContents().stream().filter(entry -> entry.name.match(aggregation.getType())).count() > 0); - final Aggregation parsedAggregation = parseAndAssert(aggregation, randomBoolean()); assertFromXContent(aggregation, (ParsedAggregation) parsedAggregation); } - //norelease TODO make abstract - protected void assertFromXContent(T aggregation, ParsedAggregation parsedAggregation) throws IOException { - } + protected abstract void assertFromXContent(T aggregation, ParsedAggregation parsedAggregation) throws IOException; @SuppressWarnings("unchecked") protected

P parseAndAssert(final InternalAggregation aggregation,