-
Notifications
You must be signed in to change notification settings - Fork 1k
/
AutoIntervalBoundariesTest.java
34 lines (28 loc) · 1.39 KB
/
AutoIntervalBoundariesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.graylog.plugins.enterprise.search.searchtypes.pivot.buckets;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.junit.Test;
import java.time.Duration;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
public class AutoIntervalBoundariesTest {
@Test
public void rangeBoundariesMustBeConnectedAndSpanEverything() {
final ImmutableMap<Range<Duration>, DateHistogramInterval> ranges = AutoInterval.boundaries.asMapOfRanges();
final int rangeCount = ranges.size();
final Range<Duration> firstRange = ranges.keySet().asList().get(0);
assertThat(firstRange.hasLowerBound()).as("first range's lower bound should be unbounded").isFalse();
final Range<Duration> lastRange = ranges.keySet().asList().get(rangeCount - 1);
assertThat(lastRange.hasUpperBound()).as("last range's upper bound should be unbounded").isFalse();
final Optional<Range<Duration>> ignored = ranges
.keySet()
.stream()
.reduce((r1, r2) -> {
assertThat(r1.isConnected(r2))
.as("ranges %s and %s must be connected", r1, r2)
.isTrue();
return r2;
});
}
}