void (boolean exists) { myFixture.configureByFile(getTestName(true) + "/Test.groovy"); String hint = GroovyIntentionsBundle.message("convert.map.to.class.intention.name"); final List<IntentionAction> list = myFixture.filterAvailableIntentions(hint); if (!exists) { assertEmpty(list); return; } assertOneElement(list); final PsiElement element = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset()); final GrListOrMap map = PsiTreeUtil.getParentOfType(element, GrListOrMap.class); assertNotNull(map); final GrTypeDefinition foo = ConvertMapToClassIntention.createClass(getProject(), map.getNamedArguments(), "", "Foo"); myFixture.addFileToProject(getTestName(true) + "/Foo.groovy", foo.getContainingFile().getText()); final PsiClass psiClass = myFixture.findClass("Foo"); WriteCommandAction.runWriteCommandAction(getProject(), () -> ConvertMapToClassIntention .replaceMapWithClass(getProject(), map, psiClass, ConvertMapToClassIntention.checkForReturnFromMethod(map), ConvertMapToClassIntention.checkForVariableDeclaration(map), ConvertMapToClassIntention.checkForMethodParameter(map))); myFixture.checkResultByFile(getTestName(true) + "/Foo.groovy", getTestName(true) + "/Expected.groovy", true); myFixture.checkResultByFile(getTestName(true) + "/Test_after.groovy", true); }