@Test public void fail_create_temp_file() throws IOException { when(fileHashes.of(any(File.class))).thenReturn("ABCDE"); new File(temp.getRoot(), "_tmp").delete(); thrown.expect(IllegalStateException.class); thrown.expectMessage("Fail to create temp file"); cache.get("sonar-foo-plugin-1.5.jar", "ABCDE", mock(FileCache.Downloader.class)); }
@CheckForNull public File get(String filename, String hash) { Path cachedFile = dir.resolve(hash).resolve(filename); if (Files.exists(cachedFile)) { return cachedFile.toFile(); } logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash)); return null; }
FileCache { @CheckForNull public File get(String filename, String hash) { Path cachedFile = dir.resolve(hash).resolve(filename); if (Files.exists(cachedFile)) { return cachedFile.toFile(); } logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash)); return null; } }
FileCache { @CheckForNull public File get(String filename, String hash) { Path cachedFile = dir.resolve(hash).resolve(filename); if (Files.exists(cachedFile)) { return cachedFile.toFile(); } logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash)); return null; } FileCache(Path dir, FileHashes fileHashes, Logger logger); }
FileCache { @CheckForNull public File get(String filename, String hash) { Path cachedFile = dir.resolve(hash).resolve(filename); if (Files.exists(cachedFile)) { return cachedFile.toFile(); } logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash)); return null; } FileCache(Path dir, FileHashes fileHashes, Logger logger); File getDir(); @CheckForNull File get(String filename, String hash); File get(String filename, String hash, Downloader downloader); }
FileCache { @CheckForNull public File get(String filename, String hash) { Path cachedFile = dir.resolve(hash).resolve(filename); if (Files.exists(cachedFile)) { return cachedFile.toFile(); } logger.debug(String.format("No file found in the cache with name %s and hash %s", filename, hash)); return null; } FileCache(Path dir, FileHashes fileHashes, Logger logger); File getDir(); @CheckForNull File get(String filename, String hash); File get(String filename, String hash, Downloader downloader);  }