SSMCache implements Cache { @Override public void put(final Object key, final Object value) { if (!cache.isEnabled()) { LOGGER.warn("Cache {} is disabled. Cannot put value under key {}", cache.getName(), key); return; } if (key != null) { final String cacheKey = getKey(key); try { LOGGER.info("Put '{}' under key {} to cache {}", new Object[] { value, key, cache.getName() }); final Object store = toStoreValue(value); cache.set(cacheKey, expiration, store, null); } catch (TimeoutException | CacheException | RuntimeException e) { logOrThrow(e, "An error has ocurred for cache {} and key {}", getName(), cacheKey, e); } } else { LOGGER.info("Cannot put to 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 putShouldExecuteWhenCacheEnabled() throws TimeoutException, CacheException { Object key = "cackeKey"; Object value = new Object(); when(cache.isEnabled()).thenReturn(true); ssmCache.put(key, value); verify(cache).set(key.toString(), expiration, value, null); }
@Test public void putNotExecutedWhenCacheDisabled() throws TimeoutException, CacheException { Object key = "cackeKey"; Object value = new Object(); when(cache.isEnabled()).thenReturn(false); ssmCache.put(key, value); verify(cache, never()).set(key.toString(), expiration, value, null); }