@@ -162,29 +162,14 @@ public void testMissingLiveIndex() throws Exception {
162162 SearchResponse responseWithout = mock (SearchResponse .class );
163163 when (responseWithout .getTook ()).thenReturn (new TimeValue (100 ));
164164 List <InternalAggregation > aggTree = new ArrayList <>(1 );
165- InternalFilter filter = mock (InternalFilter .class );
166165
167166 List <InternalAggregation > subaggs = new ArrayList <>(2 );
168167 Map <String , Object > metadata = Maps .newMapWithExpectedSize (1 );
169168 metadata .put (RollupField .ROLLUP_META + "." + RollupField .COUNT_FIELD , "foo." + RollupField .COUNT_FIELD );
170- Sum sum = mock (Sum .class );
171- when (sum .value ()).thenReturn (10.0 );
172- when (sum .value ()).thenReturn (10.0 );
173- when (sum .getName ()).thenReturn ("foo" );
174- when (sum .getMetadata ()).thenReturn (metadata );
175- when (sum .getType ()).thenReturn (SumAggregationBuilder .NAME );
176- subaggs .add (sum );
177-
178- Sum count = mock (Sum .class );
179- when (count .value ()).thenReturn (2.0 );
180- when (count .value ()).thenReturn (2.0 );
181- when (count .getName ()).thenReturn ("foo." + RollupField .COUNT_FIELD );
182- when (count .getMetadata ()).thenReturn (null );
183- when (count .getType ()).thenReturn (SumAggregationBuilder .NAME );
184- subaggs .add (count );
185-
186- when (filter .getAggregations ()).thenReturn (InternalAggregations .from (subaggs ));
187- when (filter .getName ()).thenReturn ("filter_foo" );
169+ subaggs .add (new Sum ("foo" , 10.0 , DocValueFormat .RAW , metadata ));
170+ subaggs .add (new Sum ("foo." + RollupField .COUNT_FIELD , 2.0 , DocValueFormat .RAW , null ));
171+
172+ InternalFilter filter = new InternalFilter ("filter_foo" , 0 , InternalAggregations .from (subaggs ), metadata );
188173 aggTree .add (filter );
189174
190175 InternalAggregations mockAggsWithout = InternalAggregations .from (aggTree );
@@ -285,33 +270,15 @@ public void testVerifyMissingNormal() {
285270 public void testTranslateRollup () throws Exception {
286271 SearchResponse response = mock (SearchResponse .class );
287272 when (response .getTook ()).thenReturn (new TimeValue (100 ));
288- List <InternalAggregation > aggTree = new ArrayList <>(1 );
289- InternalFilter filter = mock (InternalFilter .class );
290273
291274 List <InternalAggregation > subaggs = new ArrayList <>(2 );
292275 Map <String , Object > metadata = Maps .newMapWithExpectedSize (1 );
293276 metadata .put (RollupField .ROLLUP_META + "." + RollupField .COUNT_FIELD , "foo." + RollupField .COUNT_FIELD );
294- Sum sum = mock (Sum .class );
295- when (sum .value ()).thenReturn (10.0 );
296- when (sum .value ()).thenReturn (10.0 );
297- when (sum .getName ()).thenReturn ("foo" );
298- when (sum .getMetadata ()).thenReturn (metadata );
299- when (sum .getType ()).thenReturn (SumAggregationBuilder .NAME );
300- subaggs .add (sum );
301-
302- Sum count = mock (Sum .class );
303- when (count .value ()).thenReturn (2.0 );
304- when (count .value ()).thenReturn (2.0 );
305- when (count .getName ()).thenReturn ("foo." + RollupField .COUNT_FIELD );
306- when (count .getMetadata ()).thenReturn (null );
307- when (count .getType ()).thenReturn (SumAggregationBuilder .NAME );
308- subaggs .add (count );
309-
310- when (filter .getAggregations ()).thenReturn (InternalAggregations .from (subaggs ));
311- when (filter .getName ()).thenReturn ("filter_foo" );
312- aggTree .add (filter );
313-
314- InternalAggregations mockAggs = InternalAggregations .from (aggTree );
277+ subaggs .add (new Sum ("foo" , 10.0 , DocValueFormat .RAW , metadata ));
278+ subaggs .add (new Sum ("foo." + RollupField .COUNT_FIELD , 2.0 , DocValueFormat .RAW , null ));
279+ InternalAggregations mockAggs = InternalAggregations .from (
280+ new InternalFilter ("filter_foo" , 0 , InternalAggregations .from (subaggs ), null )
281+ );
315282 when (response .getAggregations ()).thenReturn (mockAggs );
316283 MultiSearchResponse multiSearchResponse = new MultiSearchResponse (
317284 new MultiSearchResponse .Item [] { new MultiSearchResponse .Item (response , null ) },
@@ -434,33 +401,15 @@ public void testSimpleReduction() throws Exception {
434401
435402 SearchResponse responseWithout = mock (SearchResponse .class );
436403 when (responseWithout .getTook ()).thenReturn (new TimeValue (100 ));
437- List <InternalAggregation > aggTree = new ArrayList <>(1 );
438- InternalFilter filter = mock (InternalFilter .class );
439404
440405 List <InternalAggregation > subaggs = new ArrayList <>(2 );
441406 Map <String , Object > metadata = Maps .newMapWithExpectedSize (1 );
442407 metadata .put (RollupField .ROLLUP_META + "." + RollupField .COUNT_FIELD , "foo." + RollupField .COUNT_FIELD );
443- Sum sum = mock (Sum .class );
444- when (sum .value ()).thenReturn (10.0 );
445- when (sum .value ()).thenReturn (10.0 );
446- when (sum .getName ()).thenReturn ("foo" );
447- when (sum .getMetadata ()).thenReturn (metadata );
448- when (sum .getType ()).thenReturn (SumAggregationBuilder .NAME );
449- subaggs .add (sum );
450-
451- Sum count = mock (Sum .class );
452- when (count .value ()).thenReturn (2.0 );
453- when (count .value ()).thenReturn (2.0 );
454- when (count .getName ()).thenReturn ("foo." + RollupField .COUNT_FIELD );
455- when (count .getMetadata ()).thenReturn (null );
456- when (count .getType ()).thenReturn (SumAggregationBuilder .NAME );
457- subaggs .add (count );
458-
459- when (filter .getAggregations ()).thenReturn (InternalAggregations .from (subaggs ));
460- when (filter .getName ()).thenReturn ("filter_foo" );
461- aggTree .add (filter );
462-
463- InternalAggregations mockAggsWithout = InternalAggregations .from (aggTree );
408+ subaggs .add (new Sum ("foo" , 10.0 , DocValueFormat .RAW , metadata ));
409+ subaggs .add (new Sum ("foo." + RollupField .COUNT_FIELD , 2.0 , DocValueFormat .RAW , null ));
410+ InternalAggregations mockAggsWithout = InternalAggregations .from (
411+ new InternalFilter ("filter_foo" , 0 , InternalAggregations .from (subaggs ), Map .of ())
412+ );
464413 when (responseWithout .getAggregations ()).thenReturn (mockAggsWithout );
465414 MultiSearchResponse .Item rolledResponse = new MultiSearchResponse .Item (responseWithout , null );
466415
0 commit comments