SSMCache implements Cache { @Override public void evict(final Object key) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot evict key {}", cache.getName(), key); return; } if (key != null) { final String cacheKey = getKey(key); try { LOGGER.info("Evict {} from cache {}", key, cache.getName()); cache.delete(cacheKey); } catch (TimeoutException | CacheException | RuntimeException e) { logOrThrow(e, "An error has ocurred for cache {} and key {}", getName(), cacheKey, e); } } else { LOGGER.info("Cannot evict from cache {} because key is null", cache.getName()); } } SSMCache(final com.google.code.ssm.Cache cache, final int expiration, final boolean allowClear, final boolean registerAliases,
            final boolean muteExceptions);  SSMCache(final com.google.code.ssm.Cache cache, final int expiration, final boolean allowClear);  SSMCache(final com.google.code.ssm.Cache cache, final int expiration);  SSMCache(final SSMCache ssmCache, final int expiration); @Override String getName(); @Override Object getNativeCache(); @Override ValueWrapper get(final Object key); @Override @SuppressWarnings("unchecked") T get(final Object key, final Class<T> type); @Override @SuppressWarnings("unchecked") T get(final Object key, final Callable<T> valueLoader); @Override void put(final Object key, final Object value); @Override ValueWrapper putIfAbsent(final Object key, final Object value); @Override void evict(final Object key); @Override void clear();  }
@Test public void evictShouldExecuteWhenCacheEnabled() throws TimeoutException, CacheException { String key = "someKey"; when(cache.isEnabled()).thenReturn(true); ssmCache.evict(key); verify(cache).delete(key); }
@Test public void evictNotExecutedWhenCacheDisabled() throws TimeoutException, CacheException { String key = "someKey"; when(cache.isEnabled()).thenReturn(false); ssmCache.evict(key); verify(cache, never()).delete(key); }