Search in sources :

Example 1 with WrapReturnValueProcessor

use of com.intellij.refactoring.wrapreturnvalue.WrapReturnValueProcessor in project intellij-community by JetBrains.

the class WrapReturnValueTest method doTest.

private void doTest(final boolean existing, String exceptionMessage, final boolean createInnerClass) {
    try {
        doTest((rootDir, rootAfter) -> {
            PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(getProject()));
            assertNotNull("Class Test not found", aClass);
            PsiMethod method = aClass.findMethodsByName("foo", false)[0];
            String wrapperClassName = "Wrapper";
            PsiClass wrapperClass = myJavaFacade.findClass(wrapperClassName, GlobalSearchScope.projectScope(getProject()));
            assertTrue(!existing || wrapperClass != null);
            PsiField delegateField = existing ? wrapperClass.findFieldByName("myField", false) : null;
            new WrapReturnValueProcessor(wrapperClassName, "", null, method, existing, createInnerClass, delegateField).run();
        });
    } catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
        if (exceptionMessage != null) {
            assertEquals(exceptionMessage, e.getMessage());
            return;
        }
        throw e;
    }
    if (exceptionMessage != null) {
        fail("Conflict was not found");
    }
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiField(com.intellij.psi.PsiField) PsiClass(com.intellij.psi.PsiClass) WrapReturnValueProcessor(com.intellij.refactoring.wrapreturnvalue.WrapReturnValueProcessor)

Aggregations

PsiClass (com.intellij.psi.PsiClass)1 PsiField (com.intellij.psi.PsiField)1 PsiMethod (com.intellij.psi.PsiMethod)1 WrapReturnValueProcessor (com.intellij.refactoring.wrapreturnvalue.WrapReturnValueProcessor)1