LoggingRateLimiter { public void addAndEnsureFrequency(T clazz) { resetAfterLimit(); frequency.add(clazz); } LoggingRateLimiter(int limit);  LoggingRateLimiter(); void addAndEnsureFrequency(T clazz); void resetAfterLimit(); void capacityAvailable(T t, long max, Runnable run);  }
@Test public void testAddAndEnsureFrequency() { for(int i=0;i<10;i++){ rateLimiter.addAndEnsureFrequency(this); } rateLimiter.capacityAvailable(this, 5, () ->fail ("failure")); }