ShardCheckpoint implements Serializable { public boolean isBeforeOrAt(KinesisRecord other) { if (shardIteratorType == AT_TIMESTAMP) { return timestamp.compareTo(other.getApproximateArrivalTimestamp()) <= 0; } int result = extendedSequenceNumber().compareTo(other.getExtendedSequenceNumber()); if (result == 0) { return shardIteratorType == AT_SEQUENCE_NUMBER; } return result < 0; } ShardCheckpoint(String streamName, String shardId, StartingPoint startingPoint);  ShardCheckpoint(
      String streamName, String shardId, ShardIteratorType shardIteratorType, Instant timestamp);  ShardCheckpoint(
      String streamName,
      String shardId,
      ShardIteratorType shardIteratorType,
      String sequenceNumber,
      Long subSequenceNumber); private  ShardCheckpoint(
      String streamName,
      String shardId,
      ShardIteratorType shardIteratorType,
      String sequenceNumber,
      Long subSequenceNumber,
      Instant timestamp); boolean isBeforeOrAt(KinesisRecord other); @Override String toString(); String getShardIterator(SimplifiedKinesisClient kinesisClient); ShardCheckpoint moveAfter(KinesisRecord record); String getStreamName(); String getShardId();  }
@Test public void testComparisonWithExtendedSequenceNumber() { assertThat( new ShardCheckpoint("", "", new StartingPoint(LATEST)) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isTrue(); assertThat( new ShardCheckpoint("", "", new StartingPoint(TRIM_HORIZON)) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isTrue(); assertThat( checkpoint(AFTER_SEQUENCE_NUMBER, "10", 1L) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isTrue(); assertThat( checkpoint(AT_SEQUENCE_NUMBER, "100", 0L) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isTrue(); assertThat( checkpoint(AFTER_SEQUENCE_NUMBER, "100", 0L) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isFalse(); assertThat( checkpoint(AT_SEQUENCE_NUMBER, "100", 1L) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("100", 0L)))) .isFalse(); assertThat( checkpoint(AFTER_SEQUENCE_NUMBER, "100", 0L) .isBeforeOrAt(recordWith(new ExtendedSequenceNumber("99", 1L)))) .isFalse(); }
@Test public void testComparisonWithTimestamp() { DateTime referenceTimestamp = DateTime.now(); assertThat( checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant()) .isBeforeOrAt(recordWith(referenceTimestamp.minusMillis(10).toInstant()))) .isFalse(); assertThat( checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant()) .isBeforeOrAt(recordWith(referenceTimestamp.toInstant()))) .isTrue(); assertThat( checkpoint(AT_TIMESTAMP, referenceTimestamp.toInstant()) .isBeforeOrAt(recordWith(referenceTimestamp.plusMillis(10).toInstant()))) .isTrue(); }