@Test
public void testTryTake() throws Exception {

    ImmutableTokenBucket next = tokenBucket;
    for (int i = 0; i < BUCKET_SIZE; i++) {
        next = doTryTake(next);
    }
    assertThat(next.tryTake()).isEmpty();
    // Advance time to refill the bucket
    testClock.advanceTime(REFILL_INTERVAL_MS, TimeUnit.MILLISECONDS);
    Pair<Long, ImmutableTokenBucket> pair = doTryTake(next, REFILL_BATCH, REFILL_BATCH);
    assertThat(pair.getLeft()).isEqualTo(REFILL_BATCH);
    assertThat(pair.getRight().tryTake()).isEmpty();
}