### Question:
ThroughputSnapshotThrottle implements SnapshotThrottle { @Override public long throttledByThroughput(final long bytes) { long availableSize; final long nowUs = Utils.monotonicUs(); final long limitPerCycle = this.throttleThroughputBytes / this.checkCycleSecs; this.lock.lock(); try { if (this.currThroughputBytes + bytes > limitPerCycle) { if (nowUs - this.lastThroughputCheckTimeUs <= 1000 * 1000 / this.checkCycleSecs) { availableSize = limitPerCycle - this.currThroughputBytes; this.currThroughputBytes = limitPerCycle; } else { availableSize = bytes > limitPerCycle ? limitPerCycle : bytes; this.currThroughputBytes = availableSize; this.lastThroughputCheckTimeUs = calculateCheckTimeUs(nowUs); } } else { availableSize = bytes; this.currThroughputBytes += availableSize; } } finally { this.lock.unlock(); } return availableSize; } ThroughputSnapshotThrottle(final long throttleThroughputBytes, final long checkCycleSecs); @Override long throttledByThroughput(final long bytes);  }### Answer:
@Test public void testThrottledByThroughput() throws Exception { assertEquals(512L, this.snapshotThrottle.throttledByThroughput(512)); assertEquals(512L, this.snapshotThrottle.throttledByThroughput(512)); assertEquals(0, this.snapshotThrottle.throttledByThroughput(512)); Thread.sleep(1100); assertEquals(512L, this.snapshotThrottle.throttledByThroughput(512)); assertEquals(512L, this.snapshotThrottle.throttledByThroughput(512)); assertEquals(0, this.snapshotThrottle.throttledByThroughput(512)); }