@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapRuntimeExceptionInMemoizationException() { final IntFunction<String> keyfunction = a -> "key"; try (final Cache<String, Long> cache = Mockito.mock(Cache.class)) { final JCacheBasedIntToLongFunctionMemoizer<String> loader = new JCacheBasedIntToLongFunctionMemoizer<>( cache, keyfunction, null); given(cache.invoke(any(), any())).willThrow(RuntimeException.class); thrown.expect(MemoizationException.class); loader.applyAsLong(123); } }
@Override public long applyAsLong(final int value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); }
JCacheBasedIntToLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements IntToLongFunction { @Override public long applyAsLong(final int value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } }
JCacheBasedIntToLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements IntToLongFunction { @Override public long applyAsLong(final int value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedIntToLongFunctionMemoizer(
            final Cache<KEY, Long> cache,
            final IntFunction<KEY> keyFunction,
            final IntToLongFunction biFunction); }
JCacheBasedIntToLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements IntToLongFunction { @Override public long applyAsLong(final int value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedIntToLongFunctionMemoizer(
            final Cache<KEY, Long> cache,
            final IntFunction<KEY> keyFunction,
            final IntToLongFunction biFunction); @Override long applyAsLong(final int value); }
JCacheBasedIntToLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements IntToLongFunction { @Override public long applyAsLong(final int value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedIntToLongFunctionMemoizer(
            final Cache<KEY, Long> cache,
            final IntFunction<KEY> keyFunction,
            final IntToLongFunction biFunction); @Override long applyAsLong(final int value);  }