Source:
public void testGetAllStoreSomeMatchCacheAccessExceptionBeforeLoaderNoMatchAllFailWithBulkCacheLoadingException() throws Exception { final FakeStore fakeStore = new FakeStore(getEntryMap(KEY_SET_A, KEY_SET_B)); this.store = spy(fakeStore); doThrow(new CacheAccessException("")).when(this.store) .bulkComputeIfAbsent(getAnyStringSet(), getAnyIterableFunction()); final FakeCacheLoaderWriter fakeLoader = new FakeCacheLoaderWriter(getEntryMap(KEY_SET_F), true); this.loaderWriter = spy(fakeLoader); final Ehcache<String, String> ehcache = this.getEhcache(this.loaderWriter); final Set<String> fetchKeys = fanIn(KEY_SET_A, KEY_SET_C); try { ehcache.getAll(fetchKeys); fail(); } catch (BulkCacheLoadingException e) { assertThat(e.getSuccesses().keySet(), empty()); assertThat(e.getFailures().keySet(), Matchers.<Set<?>>equalTo(fetchKeys)); } final InOrder ordered = inOrder(this.loaderWriter, this.spiedResilienceStrategy); verify(this.store).bulkComputeIfAbsent(eq(fetchKeys), getAnyIterableFunction()); ordered.verify(this.loaderWriter, atLeast(1)).loadAll(this.loadAllCaptor.capture()); assertThat(this.getLoadAllArgs(), equalTo(fetchKeys)); ordered.verify(this.spiedResilienceStrategy) .getAllFailure(eq(fetchKeys), any(CacheAccessException.class), this.bulkExceptionCaptor.capture()); assertThat(this.bulkExceptionCaptor.getValue().getSuccesses().keySet(), empty()); assertThat(this.bulkExceptionCaptor.getValue().getFailures().keySet(), Matchers.<Set<?>>equalTo(fetchKeys)); validateStats(ehcache, EnumSet.noneOf(CacheOperationOutcomes.GetOutcome.class)); validateStats(ehcache, EnumSet.noneOf(CacheOperationOutcomes.CacheLoadingOutcome.class)); }

Target:
public void testGetAllStoreSomeMatchCacheAccessExceptionBeforeLoaderNoMatchAllFailWithBulkCacheLoadingException() throws Exception { final FakeStore fakeStore = new FakeStore(getEntryMap(KEY_SET_A, KEY_SET_B)); this.store = spy(fakeStore); doThrow(new CacheAccessException("")).when(this.store) .bulkComputeIfAbsent(getAnyStringSet(), getAnyIterableFunction()); final Set<String> fetchKeys = fanIn(KEY_SET_A, KEY_SET_C); final FakeCacheLoaderWriter fakeLoader = new FakeCacheLoaderWriter(TEST_ENTRIES, fetchKeys, true); this.loaderWriter = spy(fakeLoader); final Ehcache<String, String> ehcache = this.getEhcache(this.loaderWriter); try { ehcache.getAll(fetchKeys); fail(); } catch (BulkCacheLoadingException e) { assertThat(e.getSuccesses().keySet(), empty()); assertThat(e.getFailures().keySet(), Matchers.<Set<?>>equalTo(fetchKeys)); } final InOrder ordered = inOrder(this.loaderWriter, this.spiedResilienceStrategy); verify(this.store).bulkComputeIfAbsent(eq(fetchKeys), getAnyIterableFunction()); ordered.verify(this.loaderWriter, atLeast(1)).loadAll(this.loadAllCaptor.capture()); assertThat(this.getLoadAllArgs(), equalTo(fetchKeys)); ordered.verify(this.spiedResilienceStrategy) .getAllFailure(eq(fetchKeys), any(CacheAccessException.class), this.bulkExceptionCaptor.capture()); verifyBulkLoadingException(this.bulkExceptionCaptor.getValue(), Collections.<String> emptySet(), fetchKeys); validateStats(ehcache, EnumSet.noneOf(CacheOperationOutcomes.GetOutcome.class)); validateStats(ehcache, EnumSet.noneOf(CacheOperationOutcomes.CacheLoadingOutcome.class)); }