@Test public void canHandleNegativeResidues() { assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, -7, 10)) .isPresent() .hasValue(SEVENTY_THREE); assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, -5, 10)) .isPresent() .hasValue(75); }
@Test public void canGetTimestampsFromRangeInTheMiddle() { assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 7, 10)) .isPresent() .hasValue(77L); assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 8, 10)) .isPresent() .hasValue(78L); }
@Test public void canGetTimestampFromRangeIfItIsTheLowerBound() { assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 3, 10)) .isPresent() .hasValue(SEVENTY_THREE); }
@Test public void canGetTimestampFromRangeIfItIsTheUpperBound() { assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 2, 10)) .isPresent() .hasValue(EIGHTY_TWO); }
@Test public void canHandleMultipleValidMatches() { assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 1, 2)) .isPresent() .satisfies(optionalLong -> { long value = optionalLong.getAsLong(); assertThat(value).isIn(73L, 75L, 77L, 79L, 81L); }); assertThat(TimestampRanges.getTimestampMatchingModulus(SEVENTY_THREE_TO_EIGHTY_TWO, 0, 2)) .isPresent() .satisfies(optionalLong -> { long value = optionalLong.getAsLong(); assertThat(value).isIn(74L, 76L, 78L, 80L, 82L); }); }