TemporaryBackupFiles { Path getDiskStoreDirectory(DiskStore diskStore, DirectoryHolder dirHolder) throws IOException { Map<DirectoryHolder, Path> tempDirByDirectoryHolder = diskStoreDirDirsByDiskStore.computeIfAbsent(diskStore, k -> new HashMap<>()); Path directory = tempDirByDirectoryHolder.get(dirHolder); if (directory != null) { return directory; } File diskStoreDir = dirHolder.getDir(); directory = diskStoreDir.toPath().resolve(diskStoreDirectoryName); Files.createDirectories(directory); tempDirByDirectoryHolder.put(dirHolder, directory); return directory; } TemporaryBackupFiles(Path directory, String diskStoreDirectoryName);   }
@Test public void returnsCreatedDirectoryForADiskStore() throws IOException { Path diskStoreDir = backupFiles.getDiskStoreDirectory(diskStore, directoryHolder); assertThat(diskStoreDir) .isEqualTo(directoryHolder.getDir().toPath().resolve(DISK_STORE_DIR_NAME)); assertThat(diskStoreDir).exists(); }
@Test public void returnsTheSameFileEachTimeForADiskStoreAndDirHolder() throws IOException { Path diskStoreDir = backupFiles.getDiskStoreDirectory(diskStore, directoryHolder); assertThat(backupFiles.getDiskStoreDirectory(diskStore, directoryHolder)) .isSameAs(diskStoreDir); }