|
54 | 54 | import java.util.function.Consumer;
|
55 | 55 |
|
56 | 56 | import static java.util.stream.Collectors.toList;
|
| 57 | +import static org.hamcrest.Matchers.both; |
57 | 58 | import static org.hamcrest.Matchers.containsString;
|
58 | 59 | import static org.hamcrest.Matchers.equalTo;
|
| 60 | +import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
| 61 | +import static org.hamcrest.Matchers.lessThanOrEqualTo; |
59 | 62 |
|
60 | 63 | public class VariableWidthHistogramAggregatorTests extends AggregatorTestCase {
|
61 | 64 |
|
@@ -428,14 +431,14 @@ public void testMultipleSegments() throws IOException{
|
428 | 431 |
|
429 | 432 | assertEquals(2, buckets.size());
|
430 | 433 |
|
431 |
| - // The smaller cluster |
432 |
| - assertEquals(4 <= buckets.get(0).getDocCount() && buckets.get(0).getDocCount() <= 6, true); |
433 |
| - assertEquals(0 <= buckets.get(0).centroid() && buckets.get(0).centroid() <= 200d, true); |
| 434 | + // The lower cluster |
| 435 | + assertThat(buckets.get(0).getDocCount(), both(greaterThanOrEqualTo(4L)).and(lessThanOrEqualTo(7L))); |
| 436 | + assertThat(buckets.get(0).centroid(), both(greaterThanOrEqualTo(0.0)).and(lessThanOrEqualTo(300.0))); |
434 | 437 | assertEquals(1, buckets.get(0).min(), deltaError);
|
435 | 438 |
|
436 |
| - // The bigger cluster |
437 |
| - assertEquals(4 <= buckets.get(1).getDocCount() && buckets.get(1).getDocCount() <= 6, true); |
438 |
| - assertEquals(800d <= buckets.get(1).centroid() && buckets.get(1).centroid() <= 1005d, true); |
| 439 | + // The higher cluster |
| 440 | + assertThat(buckets.get(1).getDocCount(), equalTo(dataset.size() - buckets.get(0).getDocCount())); |
| 441 | + assertThat(buckets.get(1).centroid(), both(greaterThanOrEqualTo(800.0)).and(lessThanOrEqualTo(1005.0))); |
439 | 442 | assertEquals(1005, buckets.get(1).max(), deltaError);
|
440 | 443 | });
|
441 | 444 |
|
|
0 commit comments