From 87f41b4c4e6fdba5546a4f413e93f24f24fe7904 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 22 Oct 2014 15:06:00 -0700 Subject: [PATCH] Tests: Improve range tests to check inclusive/exclusive on ends. closes #8199 --- .../elasticsearch/search/aggregations/bucket/RangeTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java index a2fddd4ae5f..48fe1eefba5 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java @@ -69,7 +69,8 @@ public class RangeTests extends ElasticsearchIntegrationTest { for (int i = 0; i < 2; i++) { builders.add(client().prepareIndex("empty_bucket_idx", "type", "" + i).setSource(jsonBuilder() .startObject() - .field(SINGLE_VALUED_FIELD_NAME, i * 2) + // shift sequence by 1, to ensure we have negative values, and value 3 on the edge of the tested ranges + .field(SINGLE_VALUED_FIELD_NAME, i * 2 - 1) .endObject())); } indexRandom(true, builders); @@ -961,7 +962,7 @@ public class RangeTests extends ElasticsearchIntegrationTest { assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); - Histogram.Bucket bucket = histo.getBucketByKey(1l); + Histogram.Bucket bucket = histo.getBucketByKey(0l); assertThat(bucket, Matchers.notNullValue()); Range range = bucket.getAggregations().get("range");