void () { myFixture.configureByText("Test.java", """ class Test { public String <caret>foo() { return "xyz"; } } """); PsiMethod method = ((PsiJavaFile)getFile()).getClasses()[0].getMethods()[0]; ExternalAnnotationsManager.getInstance(getProject()).annotateExternally(method, CommonClassNames.JAVA_LANG_OVERRIDE, getFile(), null); IntentionAction action = myFixture.findSingleIntention("Insert '@Override'"); assertEquals(""" class Test { @Override public String foo() { return "xyz"; } } ---------- <root> </root>""", myFixture.getIntentionPreviewText(action)); myFixture.launchAction(action); myFixture.checkResult(""" class Test { @Override public String foo() { return "xyz"; } } """); }