@Test void testCacheException() throws Exception { when(mockCache.get(any(), any())).thenThrow(ExecutionException.class); final TrellisCache<String, String> cache = new TrellisCache<>(mockCache); assertThrows(TrellisRuntimeException.class, () -> cache.get("long", x -> x + "er")); }
@Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); @Override V get(final K key, final Function<K, V> mapper); }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); @Override V get(final K key, final Function<K, V> mapper);  }