### Question:
LRUCache { V get(K key) { Entry<V> entry = cache.computeIfPresent(key, this::moveEntryToStart); return entry == null ? null : entry.value; } LRUCache(int maxSize);   }### Answer:
@Test public void testCache() throws Exception { LRUCache<Integer, Integer> lruCache = new LRUCache<>(0); testWorker(lruCache, k -> { return Integer.valueOf(1); }); validateCache(lruCache, 0); testWorker(lruCache, k -> { return Integer.valueOf(k); }); validateCache(lruCache, 0); lruCache = new LRUCache<>(1); testWorker(lruCache, k -> { return Integer.valueOf(1); }); validateCache(lruCache, 1); assertNotNull(lruCache.get(Integer.valueOf(1))); testWorker(lruCache, k -> { return Integer.valueOf(k); }); validateCache(lruCache, 1); assertNull(lruCache.get(Integer.valueOf(1))); lruCache = new LRUCache<>(Runtime.getRuntime().availableProcessors() * 2); testWorker(lruCache, k -> { return Integer.valueOf(1); }); validateCache(lruCache, 1); assertNotNull(lruCache.get(Integer.valueOf(1))); testWorker(lruCache, k -> { return Integer.valueOf(k); }); validateCache(lruCache, Runtime.getRuntime().availableProcessors() * 2); assertNull(lruCache.get(Integer.valueOf(1))); lruCache = new LRUCache<>(2048); testWorker(lruCache, k -> { return Integer.valueOf(1); }); validateCache(lruCache, 1); assertNotNull(lruCache.get(Integer.valueOf(1))); testWorker(lruCache, k -> { return Integer.valueOf(k); }); validateCache(lruCache, 2048); assertNull(lruCache.get(Integer.valueOf(1))); }