void () { WriteCommandAction.runWriteCommandAction(getProject(), () -> { String fileName = getTestName(false) + ".java"; PsiFile file = myFixture.configureByFile(fileName); Set<ImportOptimizer> optimizers = LanguageImportStatements.INSTANCE.forFile(file); for (ImportOptimizer optimizer : optimizers) { if (optimizer instanceof JavaImportOptimizer) { Runnable runnable = optimizer.processFile(file); assertTrue(runnable instanceof ImportOptimizer.CollectingInfoRunnable); runnable.run(); ImportOptimizer.CollectingInfoRunnable infoRunnable = (ImportOptimizer.CollectingInfoRunnable)runnable; String info = infoRunnable.getUserNotificationInfo(); assertEquals("Removed 2 imports", info); } } }); }