private TimestampPartitioningMap<Integer> installNewVersionInMap( TimestampPartitioningMap<Integer> sourceMap, long bound, int newVersion) { return sourceMap.copyInstallingNewValue(bound, newVersion); }
@Test public void supportsRevertingVersions() { TimestampPartitioningMap newMap = DEFAULT_INITIAL_MAPPING .copyInstallingNewValue(TIMESTAMP_1, 2) .copyInstallingNewValue(TIMESTAMP_2, 1); assertThat(newMap.getValueForTimestamp(TIMESTAMP_2 - 1)).isEqualTo(2); assertThat(newMap.getValueForTimestamp(TIMESTAMP_2)).isEqualTo(1); }
@Test public void throwsWhenInstallingVersionInThePast() { TimestampPartitioningMap<Integer> newMap = DEFAULT_INITIAL_MAPPING.copyInstallingNewValue(TIMESTAMP_2, 2); assertThatThrownBy(() -> newMap.copyInstallingNewValue(TIMESTAMP_1, 2)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Cannot install a new value at an earlier timestamp"); } }
@Test public void copiesWithNewVersions() { TimestampPartitioningMap newMap = DEFAULT_INITIAL_MAPPING.copyInstallingNewValue(TIMESTAMP_1, 2); assertThat(newMap.getValueForTimestamp(TIMESTAMP_1 - 1)).isEqualTo(1); assertThat(newMap.getValueForTimestamp(TIMESTAMP_1)).isEqualTo(2); assertThat(newMap.getValueForTimestamp(TIMESTAMP_2)).isEqualTo(2); }
private TimestampPartitioningMap<Integer> installNewVersionInMap( TimestampPartitioningMap<Integer> sourceMap, long bound, int newVersion) { return sourceMap.copyInstallingNewValue(bound, newVersion); }