CacheStrategyImpl implements CacheStrategy { @Override public boolean loadFully(long numEntriesSize, long cnt) { if (numEntriesSize <= maxPaths && cnt < threshold) { return true; } else { fullyLoaded = false; return false; } } CacheStrategyImpl(ConfigurationParameters options, boolean isRefresh); @Override long maxSize(); @Override boolean loadFully(long numEntriesSize, long cnt); @Override boolean usePathEntryMap(long cnt);  }
@Test public void testThreshold() { long maxPaths = 5; CacheStrategy cs = new CacheStrategyImpl(ConfigurationParameters.of(EAGER_CACHE_MAXPATHS_PARAM, maxPaths), false); long[] cnts = new long[] {Long.MIN_VALUE, 0L, 1L, 10L, 1000L, Long.MAX_VALUE-1}; for (long cnt : cnts) { assertTrue(cs.loadFully(maxPaths-1, cnt)); assertTrue(cs.loadFully(maxPaths, cnt)); assertFalse(cs.loadFully(maxPaths+1, cnt)); } assertFalse(cs.loadFully(maxPaths+1, Long.MAX_VALUE)); }
@Test public void testThresholdIsRefresh() { long maxSize = 10; long maxPaths = 5; CacheStrategy cs = new CacheStrategyImpl(ConfigurationParameters.of( EAGER_CACHE_SIZE_PARAM, maxSize, EAGER_CACHE_MAXPATHS_PARAM, maxPaths), true); for (long cnt : new long[] {Long.MIN_VALUE, 0L, 1L, 10L-1}) { assertTrue(cs.loadFully(maxPaths-1, cnt)); assertTrue(cs.loadFully(maxPaths, cnt)); assertFalse(cs.loadFully(maxPaths+1, cnt)); } for (long cnt : new long[] {10L, 1000L, Long.MAX_VALUE}) { assertFalse(cs.loadFully(maxPaths-1, cnt)); assertFalse(cs.loadFully(maxPaths, cnt)); assertFalse(cs.loadFully(maxPaths+1, cnt)); } }