DefaultCache implements Cache<KeyType, ValueType> { @Override public ValueType get(KeyType key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } CacheEntry<KeyType, ValueType> result = cacheMap.get(key); if (result == null) { return null; } else { return result.getValue(); } } DefaultCache(final String name, final int maximumSize); @Override void clear(); @Override synchronized void put(KeyType key, ValueType value); @Override ValueType get(KeyType key); @Override String getName(); @Override long getSize(); @Override int getMaxSize(); @Override boolean containsKey(KeyType key); @Override String toString();  }
@Test(expected = IllegalArgumentException.class) public void testGetNull() { Cache cache = new DefaultCache(getRandomString(), 5); cache.get(null); }