void (final boolean checkMembersMovedCount, String conflictMessage, RefactoringTestUtil.MemberDescriptor... membersToFind) { final MultiMap<PsiElement, String> conflictsMap = new MultiMap<>(); configureByFile(BASE_PATH + getTestName(false) + ".java"); PsiElement elementAt = getFile().findElementAt(getEditor().getCaretModel().getOffset()); final PsiClass sourceClass = PsiTreeUtil.getParentOfType(elementAt, PsiClass.class); assertNotNull(sourceClass); PsiClass targetClass = sourceClass.getSuperClass(); assertNotNull(targetClass); if (!targetClass.isWritable()) { final PsiClass[] interfaces = sourceClass.getInterfaces(); assertEquals(1, interfaces.length); assertTrue(interfaces[0].isWritable()); targetClass = interfaces[0]; } final MemberInfo[] infos = membersToFind.length == 0 ? new MemberInfo[]{new MemberInfo(PsiTreeUtil.getParentOfType(elementAt, PsiMember.class))} : RefactoringTestUtil.findMembers(sourceClass, membersToFind); final int[] countMoved = {0}; final MoveMemberListener listener = (aClass, member) -> { assertEquals(sourceClass, aClass); countMoved[0]++; }; JavaRefactoringListenerManager.getInstance(getProject()).addMoveMembersListener(listener); final PsiDirectory targetDirectory = targetClass.getContainingFile().getContainingDirectory(); final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null; conflictsMap.putAllValues( PullUpConflictsUtil .checkConflicts(infos, sourceClass, targetClass, targetPackage, targetDirectory, psiMethod -> PullUpProcessor.checkedInterfacesContain(Arrays.asList(infos), psiMethod)) ); final PullUpProcessor helper = new PullUpProcessor(sourceClass, targetClass, infos, new DocCommentPolicy(DocCommentPolicy.ASIS)); helper.run(); UIUtil.dispatchAllInvocationEvents(); JavaRefactoringListenerManager.getInstance(getProject()).removeMoveMembersListener(listener); if (conflictMessage != null && conflictsMap.isEmpty()) { fail("Conflict was not detected"); } if (conflictMessage == null && !conflictsMap.isEmpty()) { fail(conflictsMap.values().iterator().next()); } if (conflictMessage != null && !IGNORE_CONFLICTS.equals(conflictMessage)) { String actualMessage = conflictsMap.values().stream().sorted().collect(Collectors.joining("\n")); assertEquals(conflictMessage, actualMessage); return; } if (checkMembersMovedCount) { assertEquals(membersToFind.length == 0 ? 1 : membersToFind.length, countMoved[0]); } checkResultByFile(BASE_PATH + getTestName(false) + "_after.java"); }