Explorar o código

Fix AutoDateHistogramAggregatorTests failures (#55947)

Christos Soulios %!s(int64=5) %!d(string=hai) anos
pai
achega
f3870e656e

+ 6 - 23
server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java

@@ -220,20 +220,12 @@ public class AutoDateHistogramAggregatorTests extends AggregatorTestCase {
         fieldType.setHasDocValues(true);
         fieldType.setName("date_field");
 
-        testCase(
-            aggregation,
-            DEFAULT_QUERY,
+        testCase(aggregation, DEFAULT_QUERY,
             iw -> {},
             (Consumer<InternalAutoDateHistogram>) 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 class AutoDateHistogramAggregatorTests extends AggregatorTestCase {
         fieldType.setHasDocValues(true);
         fieldType.setName("date_field");
 
-        testCase(
-            aggregation,
-            DEFAULT_QUERY,
+        testCase(aggregation, DEFAULT_QUERY,
             iw -> {},
             (Consumer<InternalAutoDateHistogram>) 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();