void () { @Language("JAVA") String text = "package java.util; class X{ Date d;}"; final PsiJavaFile file = configureByText(text); assertEmpty(highlightErrors()); WriteCommandAction.writeCommandAction(getProject()).run(() -> { JavaCodeStyleSettings settings = JavaCodeStyleSettings.getInstance(file); ImportHelper importHelper = new ImportHelper(settings); PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("java.sql.Date", GlobalSearchScope.allScope(getProject())); boolean b = importHelper.addImport(file, psiClass); assertFalse(b); // must fail; }); }