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;
  }
@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();
  }