FileManager { public Single<Long> purgeCache() { return cacheHelper.cleanCache() .toSingle() .flatMap(cleaned -> downloadManager.invalidateDatabase() .andThen(Single.just(cleaned))); } FileManager(CacheHelper cacheHelper, FileUtils fileUtils, String[] cacheFolders,
      AptoideDownloadManager downloadManager, L2Cache httpClientCache); Single<Long> purgeCache(); Observable<Long> deleteCache();  }
@Test public void cleanCacheAndInvalidateDatabase() { FileManager fileManager = new FileManager(cacheHelper, fileUtils, folders, downloadManager, mock(L2Cache.class)); TestSubscriber<Long> subscriber = TestSubscriber.create(); fileManager.purgeCache() .subscribe(subscriber); subscriber.awaitTerminalEvent(); assertSubscriber(subscriber, 10L); verify(cacheHelper, times(1)).cleanCache(); verify(downloadManager, times(1)).invalidateDatabase(); }