LoggingRateLimiter { public void capacityAvailable(T t, long max, Runnable run) { if (frequency.count(t) < max) run.run(); } LoggingRateLimiter(int limit);  LoggingRateLimiter(); void addAndEnsureFrequency(T clazz); void resetAfterLimit(); void capacityAvailable(T t, long max, Runnable run);  }
@Test public void testCapacityAvailable() { ran = false; rateLimiter.capacityAvailable(this, 100, () -> { ran = true;}); assertTrue( ran); }