private void renameMustWork( String methodName, String newMethodName, String[] signatures, boolean updateReferences) throws Exception { final Project project = RwRefactoringTestUtils.createMutableProject(getInitialProject()); project.getProjectLoader().build(); BinTypeRef aRef = project.findTypeRefForName("p.A"); BinTypeRef[] params = RenameMethodTest.convertSingature(project, signatures); BinMethod m = MethodInvocationRules.getMethodDeclaration(aRef.getBinCIType(), aRef, methodName, params); String debugString = RenameMethodTest.filesToString(project); assertNotNull(m); RenameMethod renamer = new RenameMethod(new NullContext(project), m); renamer.setNewName(newMethodName); RefactoringStatus status = renamer.checkPreconditions(); status.merge(renamer.checkUserInput()); status.merge(renamer.apply()); if (!status.isOk()) { fail("Should have worked" + debugString); } }
private void renameMustFail(String methodName, String newMethodName, String[] signatures) throws Exception { final Project project = RwRefactoringTestUtils.createMutableProject(getInitialProject()); project.getProjectLoader().build(); BinTypeRef aRef = project.findTypeRefForName("p.A"); BinTypeRef[] params = RenameMethodTest.convertSingature(project, signatures); BinMethod m = MethodInvocationRules.getMethodDeclaration(aRef.getBinCIType(), aRef, methodName, params); String debugString = RenameMethodTest.filesToString(project); assertNotNull(m); RenameMethod renamer = new RenameMethod(new NullContext(project), m); renamer.setNewName(newMethodName); RefactoringStatus status = renamer.checkPreconditions(); status.merge(renamer.checkUserInput()); status.merge(renamer.apply()); if (status.isOk()) { fail("Should have failed" + debugString); } /* IType classA= getType(createCUfromTestFile(getPackageP(), "A"), "A"); RenameMethodRefactoring ref= RenameMethodRefactoring.createInstance(classA.getMethod(methodName, signatures)); ref.setNewName(newMethodName); RefactoringStatus result= performRefactoring(ref); assertNotNull("precondition was supposed to fail", result); */ }