@Test public void tryTakeShouldNotGetToken() { TestRefillStrategy testRefillStrategy = createTestRefillStrategy(); TokenBucket tokenBucket = createTokenBucket(10, testRefillStrategy, 0); boolean gotToken = tokenBucket.tryTake(); assertFalse(gotToken); testRefillStrategy.setAmountToRefill(5); gotToken = tokenBucket.tryTake(6); assertFalse(gotToken); }
@Override public boolean tryTake() { return tryTake(1); }
DefaultTokenBucket implements TokenBucket { @Override public boolean tryTake() { return tryTake(1); } }
DefaultTokenBucket implements TokenBucket { @Override public boolean tryTake() { return tryTake(1); } DefaultTokenBucket(String name, long capacity, RefillStrategy refillStrategy, long initialNumberOfTokens); }
DefaultTokenBucket implements TokenBucket { @Override public boolean tryTake() { return tryTake(1); } DefaultTokenBucket(String name, long capacity, RefillStrategy refillStrategy, long initialNumberOfTokens); @Override String getName(); @Override long getCapacity(); @Override long getNumberOfTokens(); @Override boolean tryTake(); @Override boolean tryTake(long numberOfTokens); @Override void take(); @Override void take(long numberOfTokens); @Override void refill(long numberOfTokens); @Override RefillStrategy getRefillStrategy(); @Override String toString(); }
DefaultTokenBucket implements TokenBucket { @Override public boolean tryTake() { return tryTake(1); } DefaultTokenBucket(String name, long capacity, RefillStrategy refillStrategy, long initialNumberOfTokens); @Override String getName(); @Override long getCapacity(); @Override long getNumberOfTokens(); @Override boolean tryTake(); @Override boolean tryTake(long numberOfTokens); @Override void take(); @Override void take(long numberOfTokens); @Override void refill(long numberOfTokens); @Override RefillStrategy getRefillStrategy(); @Override String toString();  }