EventDiskCache { public synchronized void cache(@NonNull List<Event> toCache) { if (!isCachingEnabled() || toCache.isEmpty()) return; checkCacheLimits(); long startTime = System.currentTimeMillis(); File container = writeEventFile(toCache); if (container != null) { mEventContainer.add(container); mCurrentSize += container.length(); } long stopTime = System.currentTimeMillis(); Timber.tag(TAG).d("Caching of %d events took %dms (%s)", toCache.size(), (stopTime - startTime), container); } EventDiskCache(Tracker tracker); synchronized void cache(@NonNull List<Event> toCache); @NonNull synchronized List<Event> uncache(); synchronized boolean isEmpty();  }
@Test public void testCachePath() { mDiskCache.cache(Collections.singletonList(new Event(1000, "test"))); File cacheFolder = new File(mBaseCacheDir, "piwik_cache"); File hostFolder = new File(cacheFolder, "testhost"); assertTrue(hostFolder.exists()); assertEquals(1, hostFolder.listFiles().length); }
@Test public void testCaching_empty() { mDiskCache.cache(Collections.emptyList()); }