### Question:
Cache { public V add(K key, V item) { if (!itemMap.containsKey(key)) { itemMap.put(key, item); keyList.addLast(key); if (keyList.size() > capacity) { final K removedKey = keyList.removeFirst(); final V removedItem = itemMap.get(removedKey); itemMap.remove(removedKey); return removedItem; } } return null; } Cache(int capacity); V add(K key, V item); boolean contains(K key); V get(K key); Collection<V> clear(); V remove(K key);  }### Answer:
@Test public void testAdd_returnsNullWhenWithinCapacity() { assertNull(cache.add(19, 22.089)); assertNull(cache.add(-6, 107.543)); }
@Test public void testAddBeyondCapacity_returnsRemovedEntry() { cache.add(0, 0.0); cache.add(1, 1.0); cache.add(2, 2.0); cache.add(3, 3.0); cache.add(4, 4.0); cache.add(5, 5.0); final Double removed = cache.add(6, 6.0); assertNotNull(removed); assertEquals(0.0, removed, 1e-8); }