DefaultCache implements Cache<KeyType, ValueType> { @Override public void clear() { cacheMap.clear(); } 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 public void testClear() { Cache<Object, String> cache = new DefaultCache<>(getRandomString(), 50); Object key = CacheKeyFactory.createKey(String.class, Integer.class); cache.put(key, "testvalue"); assertEquals("cache should contain entry", 1, cache.getSize()); cache.clear(); assertEquals("cache should have been cleared", 0, cache.getSize()); }