From f3870e656ec3be0086d6c8315dd9f2267e04aeeb Mon Sep 17 00:00:00 2001 From: Christos Soulios <1561376+csoulios@users.noreply.github.com> Date: Wed, 29 Apr 2020 18:20:22 +0300 Subject: [PATCH] Fix AutoDateHistogramAggregatorTests failures (#55947) --- .../AutoDateHistogramAggregatorTests.java | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java index 478cde1ebdaa4..f6e28f7615fbc 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java @@ -220,20 +220,12 @@ public void testAggregateWrongField() throws IOException { fieldType.setHasDocValues(true); fieldType.setName("date_field"); - testCase( - aggregation, - DEFAULT_QUERY, + testCase(aggregation, DEFAULT_QUERY, iw -> {}, (Consumer) histogram -> { - // TODO: searchAndReduce incorrectly returns null for empty aggs - assertNull(histogram); - /* assertEquals(0, histogram.getBuckets().size()); assertFalse(AggregationInspectionHelper.hasValue(histogram)); - */ - }, - fieldType - ); + }, fieldType); } public void testUnmappedMissing() throws IOException { @@ -245,23 +237,14 @@ public void testUnmappedMissing() throws IOException { fieldType.setHasDocValues(true); fieldType.setName("date_field"); - testCase( - aggregation, - DEFAULT_QUERY, + testCase(aggregation, DEFAULT_QUERY, iw -> {}, (Consumer) histogram -> { - // TODO: searchAndReduce incorrectly returns null for empty aggs - assertNull(histogram); - /* - assertEquals(1, histogram.getBuckets().size()); - assertTrue(AggregationInspectionHelper.hasValue(histogram)); - */ - }, - fieldType - ); + assertEquals(0, histogram.getBuckets().size()); + assertFalse(AggregationInspectionHelper.hasValue(histogram)); + }, fieldType); } - public void testIntervalYear() throws IOException { final long start = LocalDate.of(2015, 1, 1).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli(); final long end = LocalDate.of(2017, 12, 31).atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli();