use of org.elasticsearch.search.aggregations.pipeline.SimpleValue in project elasticsearch by elastic.
the class MovAvgIT method assertBucketContents.
private void assertBucketContents(Histogram.Bucket actual, Double expectedCount, Double expectedValue) {
// This is a gap bucket
SimpleValue countMovAvg = actual.getAggregations().get("movavg_counts");
if (expectedCount == null) {
assertThat("[_count] movavg is not null", countMovAvg, nullValue());
} else if (Double.isNaN(expectedCount)) {
assertThat("[_count] movavg should be NaN, but is [" + countMovAvg.value() + "] instead", countMovAvg.value(), equalTo(Double.NaN));
} else {
assertThat("[_count] movavg is null", countMovAvg, notNullValue());
assertTrue("[_count] movavg does not match expected [" + countMovAvg.value() + " vs " + expectedCount + "]", nearlyEqual(countMovAvg.value(), expectedCount, 0.1));
}
// This is a gap bucket
SimpleValue valuesMovAvg = actual.getAggregations().get("movavg_values");
if (expectedValue == null) {
assertThat("[value] movavg is not null", valuesMovAvg, Matchers.nullValue());
} else if (Double.isNaN(expectedValue)) {
assertThat("[value] movavg should be NaN, but is [" + valuesMovAvg.value() + "] instead", valuesMovAvg.value(), equalTo(Double.NaN));
} else {
assertThat("[value] movavg is null", valuesMovAvg, notNullValue());
assertTrue("[value] movavg does not match expected [" + valuesMovAvg.value() + " vs " + expectedValue + "]", nearlyEqual(valuesMovAvg.value(), expectedValue, 0.1));
}
}
Aggregations