void () { String text = "package aaa; class A{}"; VirtualFile vFile = myFixture.addFileToProject("A.java", text).getVirtualFile(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiFile file = getPsiManager().findFile(vFile); PsiJavaFile fileACopy = (PsiJavaFile)file.copy(); PsiClass aClass = fileACopy.getClasses()[0]; aClass.setName("ANew"); PsiFile newFile = (PsiFile)file.getContainingDirectory().add(fileACopy); Document document = PsiDocumentManager.getInstance(getProject()).getDocument(newFile); FileDocumentManager.getInstance().saveDocument(document); assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp()); assertFalse(FileDocumentManager.getInstance().isFileModified(newFile.getVirtualFile())); }