GetCacheVersion extends CacheVersion { Observable<Integer> react() { Integer currentVersion = persistence.retrieve(KEY_CACHE_VERSION, Integer.class, false, null); currentVersion = currentVersion == null ? 0 : currentVersion; return Observable.just(currentVersion); } @Inject  GetCacheVersion(Persistence persistence);   }
@Test public void When_No_Version_Specified_Then_Return_0() { TestObserver<Integer> versionTestObserver = getCacheVersionUT.react().test(); versionTestObserver.awaitTerminalEvent(); int currentVersion = versionTestObserver.values().get(0); assertThat(currentVersion, is(0)); }
@Test public void When_Version_Specified_Then_Get_It() { disk.save(io.rx_cache2.internal.migration.GetCacheVersion.KEY_CACHE_VERSION, 5, false, null); TestObserver<Integer> versionTestObserver = getCacheVersionUT.react().test(); versionTestObserver.awaitTerminalEvent(); int currentVersion = versionTestObserver.values().get(0); assertThat(currentVersion, is(5)); }