public VersionedType<T> getVersionedValue() { return delegate.get(); } }
@Override public T getValue() { return delegate.get().value(); }
@Test public void versionUpdatesForGetAfterRefreshMillis() throws InterruptedException { assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 1L)); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 2L)); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 3L)); }
@Test public void canUpdateForNewKeys() throws InterruptedException { assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 1L)); supplier.update(1, 1L); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(1L, UNINITIALIZED_VERSION + 2L)); supplier.update(2, 100L); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(100L, UNINITIALIZED_VERSION + 3L)); }
@Test public void canUpdateForExistingKeys() throws InterruptedException { assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 1L)); supplier.update(2, 100L); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(100L, UNINITIALIZED_VERSION + 2L)); supplier.update(2, 10L); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(10L, UNINITIALIZED_VERSION + 3L)); }
@Test public void versionDoesNotUpdateUntilGetIsCalled() throws InterruptedException { assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 1L)); waitForUpdate(); waitForUpdate(); waitForUpdate(); assertThat(supplier.get()).isEqualTo(VersionedType.of(0L, UNINITIALIZED_VERSION + 2L)); }
public VersionedType<T> getVersionedValue() { return delegate.get(); } }
@Override public T getValue() { return delegate.get().value(); }