OffsetRangeTracker extends RestrictionTracker<OffsetRange, Long> implements HasProgress { @Override public void checkDone() throws IllegalStateException { if (range.getFrom() == range.getTo()) { return; } checkState( lastAttemptedOffset != null, "Last attempted offset should not be null. No work was claimed in non-empty range %s.", range); checkState( lastAttemptedOffset >= range.getTo() - 1, "Last attempted offset was %s in range %s, claiming work in [%s, %s) was not attempted", lastAttemptedOffset, range, lastAttemptedOffset + 1, range.getTo()); } OffsetRangeTracker(OffsetRange range); @Override OffsetRange currentRestriction(); @Override SplitResult<OffsetRange> trySplit(double fractionOfRemainder); @Override boolean tryClaim(Long i); @Override void checkDone(); @Override IsBounded isBounded(); @Override String toString(); @Override Progress getProgress();  }
@Test public void testDoneBeforeClaim() throws Exception { expected.expectMessage( "Last attempted offset should not be null. No work was claimed in non-empty range [100, 200)"); OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200)); tracker.checkDone(); }