@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapRuntimeExceptionInMemoizationException() { final BiFunction<String, String, String> keyfunction = hashCodeKeyFunction(); try (final Cache<String, String> cache = Mockito.mock(Cache.class)) { final JCacheBasedBiConsumerMemoizer<String, String, String> loader = new JCacheBasedBiConsumerMemoizer<>( cache, keyfunction, null); given(cache.invoke(any(), any())).willThrow(RuntimeException.class); thrown.expect(MemoizationException.class); loader.accept("first", "second"); } }
@Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); invoke(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); }
JCacheBasedBiConsumerMemoizer extends AbstractJCacheBasedMemoizer<KEY, KEY> implements BiConsumer<FIRST, SECOND> { @Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); invoke(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); } }
JCacheBasedBiConsumerMemoizer extends AbstractJCacheBasedMemoizer<KEY, KEY> implements BiConsumer<FIRST, SECOND> { @Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); invoke(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); } JCacheBasedBiConsumerMemoizer(
            final Cache<KEY, KEY> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final BiConsumer<FIRST, SECOND> biConsumer); }
JCacheBasedBiConsumerMemoizer extends AbstractJCacheBasedMemoizer<KEY, KEY> implements BiConsumer<FIRST, SECOND> { @Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); invoke(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); } JCacheBasedBiConsumerMemoizer(
            final Cache<KEY, KEY> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final BiConsumer<FIRST, SECOND> biConsumer); @Override void accept(final FIRST first, final SECOND second); }
JCacheBasedBiConsumerMemoizer extends AbstractJCacheBasedMemoizer<KEY, KEY> implements BiConsumer<FIRST, SECOND> { @Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); invoke(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); } JCacheBasedBiConsumerMemoizer(
            final Cache<KEY, KEY> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final BiConsumer<FIRST, SECOND> biConsumer); @Override void accept(final FIRST first, final SECOND second);  }