@Test
public void testDiscardsBuckets()
        throws Exception
{

    SparseTimeStat distribution = new SparseTimeStat();
    distribution.add(100, MILLISECONDS);
    distribution.setBucketIdProvider(bucketIdProvider);
    distribution.add(1, MILLISECONDS);
    assertPreviousDistributionEmpty(distribution);
    ++bucketIdProvider.id;
    distribution.add(2, MILLISECONDS);
    distribution.add(3, MILLISECONDS);
    assertPreviousDistribution(distribution, 1, .001, .001, .001);
    ++bucketIdProvider.id;
    ++bucketIdProvider.id;
    distribution.add(0.1, SECONDS);
    assertPreviousDistributionEmpty(distribution);
    ++bucketIdProvider.id;
    assertPreviousDistribution(distribution, 1, .1, .1, .1);
    distribution.add(0.2, SECONDS);
    ++bucketIdProvider.id;
    ++bucketIdProvider.id;
    assertPreviousDistributionEmpty(distribution);
}