AbstractCache implements IDataCache<T> { @Override public boolean hasStorageFor(long size) { return size <= getFreeSpace(); } 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 testHasStorageFor() { AbstractCacheWrapper uut = new AbstractCacheWrapper(entries, null, 6500, predicate -> true); assertTrue(uut.hasStorageFor(c0.getByteSize())); assertTrue(uut.hasStorageFor(c1.getByteSize())); assertTrue(uut.hasStorageFor(c2.getByteSize())); assertTrue(uut.hasStorageFor(c3.getByteSize())); uut.cacheData(c0); uut.cacheData(c1); assertTrue(uut.hasStorageFor(c0.getByteSize())); assertTrue(uut.hasStorageFor(c1.getByteSize())); assertTrue(uut.hasStorageFor(c2.getByteSize())); assertFalse(uut.hasStorageFor(c3.getByteSize())); uut.cacheData(c2); assertFalse(uut.hasStorageFor(c0.getByteSize())); assertFalse(uut.hasStorageFor(c1.getByteSize())); assertFalse(uut.hasStorageFor(c2.getByteSize())); assertFalse(uut.hasStorageFor(c3.getByteSize())); }