DefaultDownloadIdCache implements DownloadIdCache { @Override public void put(final String downloadId, final DownloadArtifactCache object) { getCache().put(downloadId, object); } @Autowired  DefaultDownloadIdCache(final CacheManager cacheManager); @Override void put(final String downloadId, final DownloadArtifactCache object); @Override DownloadArtifactCache get(final String downloadId); @Override void evict(final String downloadId);  }
@Test @Description("Verifies that putting key and value is delegated to the CacheManager implementation") public void putKeyAndValueIsDelegatedToCacheManager() { final DownloadArtifactCache value = new DownloadArtifactCache(DownloadType.BY_SHA1, knownKey); underTest.put(knownKey, value); verify(cacheMock).put(cacheManagerKeyCaptor.capture(), cacheManagerValueCaptor.capture()); assertThat(cacheManagerKeyCaptor.getValue()).isEqualTo(knownKey); assertThat(cacheManagerValueCaptor.getValue()).isEqualTo(value); }
@Test @Description("Verifies that TenancyCacheManager is using direct cache because download-ids are global unique and don't need to run as tenant aware") public void tenancyCacheManagerIsUsingDirectCache() { underTest = new DefaultDownloadIdCache(tenancyCacheManagerMock); final DownloadArtifactCache value = new DownloadArtifactCache(DownloadType.BY_SHA1, knownKey); underTest.put(knownKey, value); verify(cacheMock).put(cacheManagerKeyCaptor.capture(), cacheManagerValueCaptor.capture()); verify(tenancyCacheManagerMock).getDirectCache(DefaultDownloadIdCache.DOWNLOAD_ID_CACHE); assertThat(cacheManagerKeyCaptor.getValue()).isEqualTo(knownKey); assertThat(cacheManagerValueCaptor.getValue()).isEqualTo(value); }