DefaultDownloadIdCache implements DownloadIdCache { @Override public DownloadArtifactCache get(final String downloadId) { final ValueWrapper valueWrapper = getCache().get(downloadId); return (valueWrapper == null) ? null : (DownloadArtifactCache) valueWrapper.get(); } @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 retrieving a value for a specific key is delegated to the CacheManager implementation") public void getValueReturnsTheAssociatedValueForKey() { final String knownKey = "12345"; final DownloadArtifactCache knownValue = new DownloadArtifactCache(DownloadType.BY_SHA1, knownKey); when(cacheMock.get(knownKey)).thenReturn(new SimpleValueWrapper(knownValue)); final DownloadArtifactCache downloadArtifactCache = underTest.get(knownKey); assertThat(downloadArtifactCache).isEqualTo(knownValue); }
@Test @Description("Verifies that retrieving a null value for a specific key is delegated to the CacheManager implementation") public void getValueReturnsNullIfNoKeyIsAssociated() { when(cacheMock.get(knownKey)).thenReturn(new SimpleValueWrapper(null)); final DownloadArtifactCache downloadArtifactCache = underTest.get(knownKey); assertThat(downloadArtifactCache).isNull(); }