void () { final MockVirtualFile file = new MockVirtualFile("test.txt", "test") { @Override public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) { long oldStamp = getModificationStamp(); setModificationStamp(LocalTimeCounter.currentTime()); myDocumentManager.contentsChanged(new VFileContentChangeEvent(null, this, oldStamp, getModificationStamp())); } }; myAskReloadFromDiskResult = Boolean.FALSE; final Document document = myDocumentManager.getDocument(file); assertNotNull(file.toString(), document); WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, "old ")); long documentStamp = document.getModificationStamp(); file.setContent(null, "xxx", false); myDocumentManager.saveAllDocuments(); assertEquals("old test", document.getText()); assertEquals(file.getModificationStamp(), document.getModificationStamp()); assertEquals("old test", new String(file.contentsToByteArray(), StandardCharsets.UTF_8)); assertEquals(documentStamp, document.getModificationStamp()); }