Skip to content

Commit f7dc7e2

Browse files
committed
Add unit tests for DateHistogramAggregator (#22714)
Adds unit tests for the date histogram aggregator. Relates #22278
1 parent 12d7ec2 commit f7dc7e2

File tree

2 files changed

+411
-4
lines changed

2 files changed

+411
-4
lines changed

core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,13 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
172172
aggs.add(a.buildAggregation(0L));
173173
}
174174
}
175-
@SuppressWarnings("unchecked")
176-
A internalAgg = (A) aggs.get(0).doReduce(aggs,
177-
new InternalAggregation.ReduceContext(root.context().bigArrays(), null));
178-
return internalAgg;
175+
if (aggs.isEmpty()) {
176+
return null;
177+
} else {
178+
@SuppressWarnings("unchecked")
179+
A internalAgg = (A) aggs.get(0).doReduce(aggs, new InternalAggregation.ReduceContext(root.context().bigArrays(), null));
180+
return internalAgg;
181+
}
179182
}
180183
}
181184

0 commit comments

Comments
 (0)