@Override
  public void checkDone() throws IllegalStateException {
    // If the range is empty, it is done
    if (range.getFrom().compareTo(range.getTo()) == 0) {
      return;
    }

    // If nothing was attempted, throws an exception
    checkState(
        lastAttemptedPosition != null,
        "Key range is non-empty %s and no keys have been attempted.",
        range);

    // If the end of the range was not attempted, throws an exception
    final Timestamp nextPosition = next(lastAttemptedPosition);
    if (nextPosition.compareTo(range.getTo()) < 0) {
      throw new IllegalStateException(
          String.format(
              "Last attempted key was %s in range %s, claiming work in [%s, %s) was not attempted",
              lastAttemptedPosition, range, nextPosition, range.getTo()));
    }
  }
@Test
  public void testCheckDoneSucceedsWhenFromIsEqualToTheEndOfTheRange() {
    final Timestamp from = Timestamp.ofTimeMicroseconds(10L);
    final TimestampRange range = TimestampRange.of(from, from);
    final TimestampRangeTracker tracker = new TimestampRangeTracker(range);

    // Method is void, succeeds if exception is not thrown
    tracker.checkDone();
  }