GuavaMache implements Mache<K, V> { @Override public V get(final K key) { try { return cache.getUnchecked(key); } catch (CacheLoader.InvalidCacheLoadException e) { return null; } } GuavaMache(final MacheLoader<K, V> cacheLoader, LoadingCache<K, V> cache); @Override String getName(); @Override UUID getId(); @Override V get(final K key); @Override void put(K key, V value); @Override void remove(K key); @Override void invalidateAll(); @Override void invalidate(K key); @Override void close(); @Override MacheLoader<K, V> getCacheLoader();  }
@Test public void missingKeyShouldReturnNull() { String missing = mache.get("Missing"); assertNull(missing); }
@Test public void canReadThrough() throws ExecutionException { String test = mache.get("TEST"); assertEquals(1, read); assertEquals("FIXTURE:loaded_TEST", test); }
@Test public void readsThroughOnceThenOnlyReadsFromCacheForSameKey() throws Exception { assertNotNull(mache.get("TEST")); assertNotNull(mache.get("TEST")); assertNotNull(mache.get("TEST")); assertEquals("Expected loader to have only been called once (the first time)", 1, read); }