GuavaCacheBasedLongToIntFunctionMemoizerTest.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:memoization.java 作者:
/**
 * @throws ExecutionException
 *             Added for the call to 'cache.get(..)'.
 */
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldWrapExecutionExceptionInMemoizationException() throws ExecutionException {
    // given
    final LongFunction<Long> keyFunction = Long::valueOf;
    final Cache<Long, Integer> cache = Mockito.mock(Cache.class);
    given(cache.get(any(), any())).willThrow(ExecutionException.class);
    final GuavaCacheBasedLongToIntFunctionMemoizer<Long> memoizer = new GuavaCacheBasedLongToIntFunctionMemoizer<>(
            cache, keyFunction, null);

    // when
    thrown.expect(MemoizationException.class);

    // then
    memoizer.applyAsInt(789);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号