@Test public void testContains() throws Exception { RxCache underlyingCache = mock(RxCache.class); LazyExpirableCache lazyExpirableCache = LazyExpirableCache.fromCache(underlyingCache, 10, TimeUnit.SECONDS, simpleTimeProvider); long currentTime = TimeUnit.HOURS.toMillis(2); when(simpleTimeProvider.currentTime()).thenReturn(currentTime); String cacheKey = "cache_key"; String testValue = "test"; when(underlyingCache.get(eq(cacheKey), any())) .thenReturn(Observable.just( new TimedValue<>(new SimpleObject(testValue), currentTime - TimeUnit.SECONDS.toMillis(5)))); Observable<Boolean> observable = lazyExpirableCache.contains(cacheKey); ObservableTestUtils.testObservable(observable, Assert::assertTrue); }
@Override public Observable<Boolean> contains(String key) { return get(key, Object.class).flatMap(o -> Observable.just(o != null)); }
LazyExpirableCache implements Cache { @Override public Observable<Boolean> contains(String key) { return get(key, Object.class).flatMap(o -> Observable.just(o != null)); } }
LazyExpirableCache implements Cache { @Override public Observable<Boolean> contains(String key) { return get(key, Object.class).flatMap(o -> Observable.just(o != null)); } private  LazyExpirableCache(RxCache underlyingCache, long expireMillis, Observable<Long> timeObservable); }
LazyExpirableCache implements Cache { @Override public Observable<Boolean> contains(String key) { return get(key, Object.class).flatMap(o -> Observable.just(o != null)); } private  LazyExpirableCache(RxCache underlyingCache, long expireMillis, Observable<Long> timeObservable); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit,
            SimpleTimeProvider simpleTimeProvider); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit,
            Observable<Long> timeObservable); @Override Observable<T> get(String key, Type type); @Override Observable<Boolean> put(String key, Object object); @Override Observable<Boolean> contains(String key); @Override Observable<Boolean> remove(String key); @Override Observable<Boolean> clear(); @Override void getAsync(String key, Type typeOfT, WaterfallGetCallback<T> callback); @Override void putAsync(String key, Object object, WaterfallCallback callback); @Override void containsAsync(String key, WaterfallGetCallback<Boolean> callback); @Override void removeAsync(String key, WaterfallCallback callback); @Override void clearAsync(WaterfallCallback callback); }
LazyExpirableCache implements Cache { @Override public Observable<Boolean> contains(String key) { return get(key, Object.class).flatMap(o -> Observable.just(o != null)); } private  LazyExpirableCache(RxCache underlyingCache, long expireMillis, Observable<Long> timeObservable); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit,
            SimpleTimeProvider simpleTimeProvider); static LazyExpirableCache fromCache(RxCache cache, long expireAfter, TimeUnit expireAfterUnit,
            Observable<Long> timeObservable); @Override Observable<T> get(String key, Type type); @Override Observable<Boolean> put(String key, Object object); @Override Observable<Boolean> contains(String key); @Override Observable<Boolean> remove(String key); @Override Observable<Boolean> clear(); @Override void getAsync(String key, Type typeOfT, WaterfallGetCallback<T> callback); @Override void putAsync(String key, Object object, WaterfallCallback callback); @Override void containsAsync(String key, WaterfallGetCallback<Boolean> callback); @Override void removeAsync(String key, WaterfallCallback callback); @Override void clearAsync(WaterfallCallback callback);  }