@Test public void shouldDelegateHandlingOfAllocationFailures() { RuntimeException failure = new RuntimeException(); RuntimeException expectedException = new RuntimeException(); doThrow(failure).when(delegate).storeUpperLimit(anyLong()); when(allocationFailures.responseTo(failure)).thenReturn(expectedException); exception.expect(is(expectedException)); store.storeUpperLimit(1_000); }
@Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); @Override long getUpperLimit(); @Override synchronized void storeUpperLimit(long limit); }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); @Override long getUpperLimit(); @Override synchronized void storeUpperLimit(long limit);  }