void () { PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()) .createFileFromText("a.java", JavaLanguage.INSTANCE, "class Foo {}\nclass Bar{}", false, false); file.getClasses()[1].delete(); String expectedText = "class Foo {}\n"; assertEquals(expectedText, file.getText()); Document document = file.getViewProvider().getDocument(); assertTrue(PsiDocumentManager.getInstance(getProject()).isCommitted(document)); assertEquals(expectedText, document.getText()); }