startCal.setTimeInMillis(time);
final Calendar endCal = Calendar.getInstance();
// theoretically should get 3 bins back the first and last not having
// full extent and the middle one being full extent
endCal.setTimeInMillis(time + (TemporalBinningStrategy.MILLIS_PER_DAY * 2));
final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
Unit.DAY);
BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
startCal.getTimeInMillis(),
endCal.getTimeInMillis()));
Assert.assertEquals(
3,
ranges.length);
Assert.assertTrue(!ranges[0].isFullExtent());
Assert.assertTrue(ranges[1].isFullExtent());
Assert.assertTrue(!ranges[2].isFullExtent());
final Calendar startCalOnEpoch = Calendar.getInstance();
startCalOnEpoch.setTimeInMillis(time);
binStrategy.setToEpoch(startCalOnEpoch);
ranges = binStrategy.getNormalizedRanges(new NumericRange(
startCalOnEpoch.getTimeInMillis(),
endCal.getTimeInMillis()));
Assert.assertEquals(
3,
ranges.length);
// now the first element should be full extent
Assert.assertTrue(ranges[0].isFullExtent());
Assert.assertTrue(ranges[1].isFullExtent());
Assert.assertTrue(!ranges[2].isFullExtent());
final Calendar endCalOnMax = Calendar.getInstance();
// theoretically should get 3 bins back the first and last not having
// full extent and the middle one being full extent
endCalOnMax.setTimeInMillis(time + (TemporalBinningStrategy.MILLIS_PER_DAY * 3));
binStrategy.setToEpoch(endCalOnMax);
endCalOnMax.add(
Calendar.MILLISECOND,
-1);
ranges = binStrategy.getNormalizedRanges(new NumericRange(
startCal.getTimeInMillis(),
endCalOnMax.getTimeInMillis()));
Assert.assertEquals(
3,
ranges.length);