### Question:
FileCache { public static CacheSession newSession() { return new CacheSession() { @NonNull private final ConcurrentHashMap<File, String> pathHashes = new ConcurrentHashMap<>(); @Override @NonNull String getDirectoryHash(@NonNull File directory) { return pathHashes.computeIfAbsent(directory, Inputs.Builder::getDirectoryHash); } @Override @NonNull String getRegularFileHash(@NonNull File regularFile) { return pathHashes.computeIfAbsent(regularFile, Inputs.Builder::getFileHash); } }; } private  FileCache(@NonNull File cacheDirectory, @NonNull LockingScope lockingScope); @NonNull static FileCache getInstanceWithMultiProcessLocking(@NonNull File cacheDirectory); @NonNull static FileCache getInstanceWithSingleProcessLocking(@NonNull File cacheDirectory); @NonNull File getCacheDirectory(); @NonNull QueryResult createFile(
            @NonNull File outputFile,
            @NonNull Inputs inputs,
            @NonNull ExceptionRunnable fileCreator); @NonNull QueryResult createFileInCacheIfAbsent(
            @NonNull Inputs inputs,
            @NonNull ExceptionConsumer<File> fileCreator); boolean cacheEntryExists(@NonNull Inputs inputs); @NonNull File getFileInCache(@NonNull Inputs inputs); void deleteOldCacheEntries(long lastTimestamp); void delete(); @Override String toString(); static CacheSession newSession();  }### Answer:
@Test public void testCacheSession() throws Exception { FileCache.CacheSession session = FileCache.newSession(); FileCache.CacheSession otherSession = FileCache.newSession(); File inputFile = temporaryFolder.newFile(); writeStringToFile("Some text", inputFile); String fileInitialKey = new FileCache.Inputs.Builder(FileCache.Command.TEST, session) .putFile("file", inputFile, FileCache.FileProperties.HASH) .build() .getKey(); writeStringToFile("Some different text", inputFile); String changedFileKeyWithoutSession = new FileCache.Inputs.Builder(FileCache.Command.TEST) .putFile("file", inputFile, FileCache.FileProperties.HASH) .build() .getKey(); String changedFileKeyWithSession = new FileCache.Inputs.Builder(FileCache.Command.TEST, session) .putFile("file", inputFile, FileCache.FileProperties.HASH) .build() .getKey(); String changedFileKeyWithOtherSession = new FileCache.Inputs.Builder(FileCache.Command.TEST, otherSession) .putFile("file", inputFile, FileCache.FileProperties.HASH) .build() .getKey(); assertThat(changedFileKeyWithoutSession).isNotEqualTo(fileInitialKey); assertThat(changedFileKeyWithSession).isEqualTo(fileInitialKey); assertThat(changedFileKeyWithOtherSession).isNotEqualTo(fileInitialKey); session = FileCache.newSession(); otherSession = FileCache.newSession(); File inputDir = temporaryFolder.newFolder(); writeSampleContentsToDirectory(inputDir); String dirInitialKey = new FileCache.Inputs.Builder(FileCache.Command.TEST, session) .putDirectory("dir", inputDir, FileCache.DirectoryProperties.HASH) .build() .getKey(); java.nio.file.Files.createDirectory(new File(inputDir, "additionalDirectory").toPath()); String changedDirKeyWithoutSession = new FileCache.Inputs.Builder(FileCache.Command.TEST) .putDirectory("dir", inputDir, FileCache.DirectoryProperties.HASH) .build() .getKey(); String changedDirKeyWithSession = new FileCache.Inputs.Builder(FileCache.Command.TEST, session) .putDirectory("dir", inputDir, FileCache.DirectoryProperties.HASH) .build() .getKey(); String changedDirKeyWithOtherSession = new FileCache.Inputs.Builder(FileCache.Command.TEST, otherSession) .putDirectory("dir", inputDir, FileCache.DirectoryProperties.HASH) .build() .getKey(); assertThat(changedDirKeyWithoutSession).isNotEqualTo(dirInitialKey); assertThat(changedDirKeyWithSession).isEqualTo(dirInitialKey); assertThat(changedDirKeyWithOtherSession).isNotEqualTo(dirInitialKey); }