@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapExecutionExceptionInMemoizationException() throws ExecutionException { final LongFunction<String> keyFunction = a -> "key"; final Cache<String, String> cache = Mockito.mock(Cache.class); given(cache.get(any(), any())).willThrow(ExecutionException.class); final GuavaCacheBasedLongFunctionMemoizer<String, String> memoizer = new GuavaCacheBasedLongFunctionMemoizer<>( cache, keyFunction, null); thrown.expect(MemoizationException.class); memoizer.apply(123); }
@Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> function.apply(value)); }
GuavaCacheBasedLongFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> function.apply(value)); } }
GuavaCacheBasedLongFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> function.apply(value)); } GuavaCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); }
GuavaCacheBasedLongFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> function.apply(value)); } GuavaCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); @Override OUTPUT apply(final long value); }
GuavaCacheBasedLongFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> function.apply(value)); } GuavaCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); @Override OUTPUT apply(final long value);  }