@Test
public void testCreatesBuckets() {

    MockedTime time = new MockedTime();
    try {
        HystrixRollingNumber counter = new HystrixRollingNumber(time, 200, 10);
        // confirm the initial settings
        assertEquals(200, counter.timeInMilliseconds);
        assertEquals(10, counter.numberOfBuckets);
        assertEquals(20, counter.bucketSizeInMillseconds);
        // we start out with 0 buckets in the queue
        assertEquals(0, counter.buckets.size());
        // add a success in each interval which should result in all 10 buckets being created with 1 success in each
        for (int i = 0; i < counter.numberOfBuckets; i++) {
            counter.increment(HystrixRollingNumberEvent.SUCCESS);
            time.increment(counter.bucketSizeInMillseconds);
        }
        // confirm we have all 10 buckets
        assertEquals(10, counter.buckets.size());
        // add 1 more and we should still only have 10 buckets since that's the max
        counter.increment(HystrixRollingNumberEvent.SUCCESS);
        assertEquals(10, counter.buckets.size());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Exception: " + e.getMessage());
    }
}