40
40
import static org .elasticsearch .common .xcontent .XContentFactory .jsonBuilder ;
41
41
import static org .elasticsearch .index .query .QueryBuilders .matchAllQuery ;
42
42
import static org .elasticsearch .search .aggregations .AggregationBuilders .*;
43
+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertSearchResponse ;
43
44
import static org .hamcrest .Matchers .equalTo ;
44
45
import static org .hamcrest .Matchers .is ;
45
46
import static org .hamcrest .core .IsNull .notNullValue ;
@@ -90,7 +91,8 @@ public void singleValuedField() throws Exception {
90
91
.addAggregation (dateHistogram ("histo" ).field ("date" ).interval (DateHistogram .Interval .MONTH ))
91
92
.execute ().actionGet ();
92
93
93
- assertThat (response .getFailedShards (), equalTo (0 ));
94
+ assertSearchResponse (response );
95
+
94
96
95
97
DateHistogram histo = response .getAggregations ().get ("histo" );
96
98
assertThat (histo , notNullValue ());
@@ -125,7 +127,8 @@ public void singleValuedField_OrderedByKeyAsc() throws Exception {
125
127
.order (DateHistogram .Order .KEY_ASC ))
126
128
.execute ().actionGet ();
127
129
128
- assertThat (response .getFailedShards (), equalTo (0 ));
130
+ assertSearchResponse (response );
131
+
129
132
130
133
DateHistogram histo = response .getAggregations ().get ("histo" );
131
134
assertThat (histo , notNullValue ());
@@ -148,7 +151,8 @@ public void singleValuedField_OrderedByKeyDesc() throws Exception {
148
151
.order (DateHistogram .Order .KEY_DESC ))
149
152
.execute ().actionGet ();
150
153
151
- assertThat (response .getFailedShards (), equalTo (0 ));
154
+ assertSearchResponse (response );
155
+
152
156
153
157
DateHistogram histo = response .getAggregations ().get ("histo" );
154
158
assertThat (histo , notNullValue ());
@@ -171,7 +175,8 @@ public void singleValuedField_OrderedByCountAsc() throws Exception {
171
175
.order (DateHistogram .Order .COUNT_ASC ))
172
176
.execute ().actionGet ();
173
177
174
- assertThat (response .getFailedShards (), equalTo (0 ));
178
+ assertSearchResponse (response );
179
+
175
180
176
181
DateHistogram histo = response .getAggregations ().get ("histo" );
177
182
assertThat (histo , notNullValue ());
@@ -194,7 +199,8 @@ public void singleValuedField_OrderedByCountDesc() throws Exception {
194
199
.order (DateHistogram .Order .COUNT_DESC ))
195
200
.execute ().actionGet ();
196
201
197
- assertThat (response .getFailedShards (), equalTo (0 ));
202
+ assertSearchResponse (response );
203
+
198
204
199
205
DateHistogram histo = response .getAggregations ().get ("histo" );
200
206
assertThat (histo , notNullValue ());
@@ -215,7 +221,8 @@ public void singleValuedField_WithSubAggregation() throws Exception {
215
221
.subAggregation (sum ("sum" ).field ("value" )))
216
222
.execute ().actionGet ();
217
223
218
- assertThat (response .getFailedShards (), equalTo (0 ));
224
+ assertSearchResponse (response );
225
+
219
226
220
227
DateHistogram histo = response .getAggregations ().get ("histo" );
221
228
assertThat (histo , notNullValue ());
@@ -257,7 +264,8 @@ public void singleValuedField_WithSubAggregation_Inherited() throws Exception {
257
264
.subAggregation (max ("max" )))
258
265
.execute ().actionGet ();
259
266
260
- assertThat (response .getFailedShards (), equalTo (0 ));
267
+ assertSearchResponse (response );
268
+
261
269
262
270
DateHistogram histo = response .getAggregations ().get ("histo" );
263
271
assertThat (histo , notNullValue ());
@@ -302,7 +310,8 @@ public void singleValuedField_OrderedBySubAggregationAsc() throws Exception {
302
310
.subAggregation (max ("sum" ).field ("value" )))
303
311
.execute ().actionGet ();
304
312
305
- assertThat (response .getFailedShards (), equalTo (0 ));
313
+ assertSearchResponse (response );
314
+
306
315
307
316
DateHistogram histo = response .getAggregations ().get ("histo" );
308
317
assertThat (histo , notNullValue ());
@@ -326,7 +335,8 @@ public void singleValuedField_OrderedBySubAggregationDesc() throws Exception {
326
335
.subAggregation (max ("sum" ).field ("value" )))
327
336
.execute ().actionGet ();
328
337
329
- assertThat (response .getFailedShards (), equalTo (0 ));
338
+ assertSearchResponse (response );
339
+
330
340
331
341
DateHistogram histo = response .getAggregations ().get ("histo" );
332
342
assertThat (histo , notNullValue ());
@@ -350,7 +360,8 @@ public void singleValuedField_OrderedByMultiValuedSubAggregationAsc_Inherited()
350
360
.subAggregation (stats ("stats" ).field ("value" )))
351
361
.execute ().actionGet ();
352
362
353
- assertThat (response .getFailedShards (), equalTo (0 ));
363
+ assertSearchResponse (response );
364
+
354
365
355
366
DateHistogram histo = response .getAggregations ().get ("histo" );
356
367
assertThat (histo , notNullValue ());
@@ -374,7 +385,8 @@ public void singleValuedField_OrderedByMultiValuedSubAggregationDesc() throws Ex
374
385
.subAggregation (stats ("stats" ).field ("value" )))
375
386
.execute ().actionGet ();
376
387
377
- assertThat (response .getFailedShards (), equalTo (0 ));
388
+ assertSearchResponse (response );
389
+
378
390
379
391
DateHistogram histo = response .getAggregations ().get ("histo" );
380
392
assertThat (histo , notNullValue ());
@@ -397,7 +409,8 @@ public void singleValuedField_WithValueScript() throws Exception {
397
409
.interval (DateHistogram .Interval .MONTH ))
398
410
.execute ().actionGet ();
399
411
400
- assertThat (response .getFailedShards (), equalTo (0 ));
412
+ assertSearchResponse (response );
413
+
401
414
402
415
DateHistogram histo = response .getAggregations ().get ("histo" );
403
416
assertThat (histo , notNullValue ());
@@ -439,7 +452,8 @@ public void multiValuedField() throws Exception {
439
452
.addAggregation (dateHistogram ("histo" ).field ("dates" ).interval (DateHistogram .Interval .MONTH ))
440
453
.execute ().actionGet ();
441
454
442
- assertThat (response .getFailedShards (), equalTo (0 ));
455
+ assertSearchResponse (response );
456
+
443
457
444
458
DateHistogram histo = response .getAggregations ().get ("histo" );
445
459
assertThat (histo , notNullValue ());
@@ -480,7 +494,8 @@ public void multiValuedField_OrderedByKeyDesc() throws Exception {
480
494
.order (DateHistogram .Order .COUNT_DESC ))
481
495
.execute ().actionGet ();
482
496
483
- assertThat (response .getFailedShards (), equalTo (0 ));
497
+ assertSearchResponse (response );
498
+
484
499
485
500
DateHistogram histo = response .getAggregations ().get ("histo" );
486
501
assertThat (histo , notNullValue ());
@@ -524,7 +539,8 @@ public void multiValuedField_WithValueScript() throws Exception {
524
539
.interval (DateHistogram .Interval .MONTH ))
525
540
.execute ().actionGet ();
526
541
527
- assertThat (response .getFailedShards (), equalTo (0 ));
542
+ assertSearchResponse (response );
543
+
528
544
529
545
DateHistogram histo = response .getAggregations ().get ("histo" );
530
546
assertThat (histo , notNullValue ());
@@ -577,7 +593,8 @@ public void multiValuedField_WithValueScript_WithInheritedSubAggregator() throws
577
593
.subAggregation (max ("max" )))
578
594
.execute ().actionGet ();
579
595
580
- assertThat (response .getFailedShards (), equalTo (0 ));
596
+ assertSearchResponse (response );
597
+
581
598
582
599
DateHistogram histo = response .getAggregations ().get ("histo" );
583
600
assertThat (histo , notNullValue ());
@@ -635,7 +652,8 @@ public void script_SingleValue() throws Exception {
635
652
.addAggregation (dateHistogram ("histo" ).script ("doc['date'].value" ).interval (DateHistogram .Interval .MONTH ))
636
653
.execute ().actionGet ();
637
654
638
- assertThat (response .getFailedShards (), equalTo (0 ));
655
+ assertSearchResponse (response );
656
+
639
657
640
658
DateHistogram histo = response .getAggregations ().get ("histo" );
641
659
assertThat (histo , notNullValue ());
@@ -670,7 +688,8 @@ public void script_SingleValue_WithSubAggregator_Inherited() throws Exception {
670
688
.subAggregation (max ("max" )))
671
689
.execute ().actionGet ();
672
690
673
- assertThat (response .getFailedShards (), equalTo (0 ));
691
+ assertSearchResponse (response );
692
+
674
693
675
694
DateHistogram histo = response .getAggregations ().get ("histo" );
676
695
assertThat (histo , notNullValue ());
@@ -711,7 +730,8 @@ public void script_MultiValued() throws Exception {
711
730
.addAggregation (dateHistogram ("histo" ).script ("doc['dates'].values" ).interval (DateHistogram .Interval .MONTH ))
712
731
.execute ().actionGet ();
713
732
714
- assertThat (response .getFailedShards (), equalTo (0 ));
733
+ assertSearchResponse (response );
734
+
715
735
716
736
DateHistogram histo = response .getAggregations ().get ("histo" );
717
737
assertThat (histo , notNullValue ());
@@ -761,7 +781,8 @@ public void script_MultiValued_WithAggregatorInherited() throws Exception {
761
781
.subAggregation (max ("max" )))
762
782
.execute ().actionGet ();
763
783
764
- assertThat (response .getFailedShards (), equalTo (0 ));
784
+ assertSearchResponse (response );
785
+
765
786
766
787
DateHistogram histo = response .getAggregations ().get ("histo" );
767
788
assertThat (histo , notNullValue ());
@@ -813,7 +834,8 @@ public void unmapped() throws Exception {
813
834
.addAggregation (dateHistogram ("histo" ).field ("date" ).interval (DateHistogram .Interval .MONTH ))
814
835
.execute ().actionGet ();
815
836
816
- assertThat (response .getFailedShards (), equalTo (0 ));
837
+ assertSearchResponse (response );
838
+
817
839
818
840
DateHistogram histo = response .getAggregations ().get ("histo" );
819
841
assertThat (histo , notNullValue ());
@@ -829,7 +851,8 @@ public void partiallyUnmapped() throws Exception {
829
851
.addAggregation (dateHistogram ("histo" ).field ("date" ).interval (DateHistogram .Interval .MONTH ))
830
852
.execute ().actionGet ();
831
853
832
- assertThat (response .getFailedShards (), equalTo (0 ));
854
+ assertSearchResponse (response );
855
+
833
856
834
857
DateHistogram histo = response .getAggregations ().get ("histo" );
835
858
assertThat (histo , notNullValue ());
0 commit comments