void () { if (!assumeHugeGistsAreEnabledAndSafeToTest()) { return; } int hugeGistSize = MAX_GIST_SIZE_TO_STORE_IN_ATTRIBUTES + 10; String hugeFileContent = "a".repeat(hugeGistSize); VirtualFile file = fileWithContent("a.txt", hugeFileContent); IntRef invocations = new IntRef(0); VirtualFileGist.GistCalculator<String> fileContentPlusProjectNameCalculator = (p, f) -> { final String content = LoadTextUtil.loadText(f).toString(); return content + "///" + (p == null ? null : p.getName()); }; VirtualFileGist<String> gistFileContentPlusProjectName = GistManager.getInstance().newVirtualFileGist( getTestName(true), 0, EnumeratorStringDescriptor.INSTANCE, wrapWithCounter( fileContentPlusProjectNameCalculator, invocations ) ); Project project1 = getProject(); Project project2 = ProjectManager.getInstance().getDefaultProject(); assertEquals( "Gist calculated 1st time for project1", fileContentPlusProjectNameCalculator.calcData(project1, file), gistFileContentPlusProjectName.getFileData(project1, file) ); assertEquals(1, invocations.get()); assertEquals( "Gist calculated 1st time for project2", fileContentPlusProjectNameCalculator.calcData(project2, file), gistFileContentPlusProjectName.getFileData(project2, file) ); assertEquals(2, invocations.get()); assertEquals( "Gist must have same value for project1", fileContentPlusProjectNameCalculator.calcData(project1, file), gistFileContentPlusProjectName.getFileData(project1, file) ); assertEquals("Gist must NOT be recalculated for project1", 2, invocations.get()); assertEquals( "Gist MUST be recalculated for null project", fileContentPlusProjectNameCalculator.calcData(null, file), gistFileContentPlusProjectName.getFileData(null, file) ); assertEquals("Gist must NOT be recalculated for null project", 3, invocations.get()); }