void () { ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject()); VirtualFile sourceRoot = rootManager.getContentSourceRoots()[0]; PsiManager psiManager = PsiManager.getInstance(getProject()); PsiDirectory psiSourceRoot = psiManager.findDirectory(sourceRoot); PsiFile psiFile = WriteAction.compute(() -> psiSourceRoot.createFile("TestDocument.xml")); PsiDirectory subdirectory = WriteAction.compute(() -> psiSourceRoot.createSubdirectory("com")); HeavyPlatformTestCase.move(psiFile.getVirtualFile(), subdirectory.getVirtualFile()); assertTrue(psiFile.isValid()); ApplicationManager.getApplication().runWriteAction(() -> psiFile.delete()); assertFalse(psiFile.isValid()); }