AbstractCache implements IDataCache<T> { @Override public long getCurrentCacheSize() { long size = 0; lock.readLock().lock(); try { size = currentCacheSize; } finally { lock.readLock().unlock(); } return size; } AbstractCache(S entries, IDataStorage<T> cachedStorage, long maxCacheSize,
      Predicate<T> cachingRule); @Override long getMaxCacheSize(); @Override boolean setMaxCacheSize(long maxCacheSize); @Override long getCurrentCacheSize(); @Override long getFreeSpace(); @Override boolean hasStorageFor(long size); @Override void cacheData(T data); @Override void uncacheData(T data); @Override boolean dataIsCachable(T data); @Override boolean dataIsInCache(long id); @Override void clearCache(); @Override boolean dataExists(long id); @Override T loadData(long id); @Override boolean saveData(T data); @Override boolean dataIsStorable(T data); @Override boolean deleteData(T data);  }
@Test public void testGetCurrentCacheSize() { AbstractCacheWrapper uut = new AbstractCacheWrapper(entries, storageAll, IDataCache.STD_MAX_CACHE_SIZE, predicate -> true); assertEquals(0, uut.getCurrentCacheSize()); uut.cacheData(c0); assertEquals(c0.getByteSize(), uut.getCurrentCacheSize()); uut.cacheData(c1); assertEquals(c0.getByteSize() + c1.getByteSize(), uut.getCurrentCacheSize()); }