@Override
 public void replayRefactoring(RefactoringDescriptor refactoringDescriptor) throws CoreException {
   try {
     // FIXME: This is a temporary hack. It is required to overcome the problem that sometimes
     // Eclipse does not finish updating
     // program's structure yet, and thus, the refactoring can not be properly initialized (i.e.
     // the refactored element is not found).
     // Find a better solution, e.g. listen for some Eclipse "refreshing" process to complete.
     Thread.sleep(1500);
   } catch (InterruptedException e) {
     // do nothing
   }
   RefactoringStatus initializationStatus = new RefactoringStatus();
   Refactoring refactoring = refactoringDescriptor.createRefactoring(initializationStatus);
   if (!initializationStatus.isOK()) {
     Debugger.debugWarning(
         "Failed to initialize a refactoring from its descriptor: " + refactoringDescriptor);
     unperformedRefactorings.add(getTime());
     return;
   }
   // This remove is needed to ensure that multiple replays in the same run do not overlap
   unperformedRefactorings.remove(getTime());
   PerformRefactoringOperation performRefactoringOperation =
       new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
   performRefactoringOperation.run(null);
   if (performRefactoringOperation.getConditionStatus().hasFatalError()) {
     throw new RuntimeException(
         "Failed to check preconditions of refactoring: " + refactoring.getName());
   }
   if (performRefactoringOperation.getValidationStatus().hasFatalError()) {
     throw new RuntimeException("Failed to validate refactoring: " + refactoring.getName());
   }
 }
 protected final Change performChange(Refactoring refactoring, boolean storeUndo)
     throws Exception {
   CreateChangeOperation create = new CreateChangeOperation(refactoring);
   PerformChangeOperation perform = new PerformChangeOperation(create);
   if (storeUndo) {
     perform.setUndoManager(getUndoManager(), refactoring.getName());
   }
   ResourcesPlugin.getWorkspace().run(perform, new NullProgressMonitor());
   assertTrue("Change wasn't executed", perform.changeExecuted());
   return perform.getUndoChange();
 }
 protected final RefactoringStatus performRefactoring(Refactoring ref, boolean providesUndo)
     throws Exception {
   performDummySearch();
   IUndoManager undoManager = getUndoManager();
   if (DESCRIPTOR_TEST) {
     final CreateChangeOperation create =
         new CreateChangeOperation(
             new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS),
             RefactoringStatus.FATAL);
     create.run(new NullProgressMonitor());
     RefactoringStatus checkingStatus = create.getConditionCheckingStatus();
     if (!checkingStatus.isOK()) return checkingStatus;
     Change change = create.getChange();
     ChangeDescriptor descriptor = change.getDescriptor();
     if (descriptor instanceof RefactoringChangeDescriptor) {
       RefactoringChangeDescriptor rcd = (RefactoringChangeDescriptor) descriptor;
       RefactoringDescriptor refactoringDescriptor = rcd.getRefactoringDescriptor();
       if (refactoringDescriptor instanceof JavaRefactoringDescriptor) {
         JavaRefactoringDescriptor jrd = (JavaRefactoringDescriptor) refactoringDescriptor;
         RefactoringStatus validation = jrd.validateDescriptor();
         if (!validation.isOK()) return validation;
         RefactoringStatus refactoringStatus = new RefactoringStatus();
         Class expected = jrd.getClass();
         RefactoringContribution contribution =
             RefactoringCore.getRefactoringContribution(jrd.getID());
         jrd =
             (JavaRefactoringDescriptor)
                 contribution.createDescriptor(
                     jrd.getID(),
                     jrd.getProject(),
                     jrd.getDescription(),
                     jrd.getComment(),
                     contribution.retrieveArgumentMap(jrd),
                     jrd.getFlags());
         assertEquals(expected, jrd.getClass());
         ref = jrd.createRefactoring(refactoringStatus);
         if (!refactoringStatus.isOK()) return refactoringStatus;
         TestRenameParticipantSingle.reset();
         TestCreateParticipantSingle.reset();
         TestMoveParticipantSingle.reset();
         TestDeleteParticipantSingle.reset();
       }
     }
   }
   final CreateChangeOperation create =
       new CreateChangeOperation(
           new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS),
           RefactoringStatus.FATAL);
   final PerformChangeOperation perform = new PerformChangeOperation(create);
   perform.setUndoManager(undoManager, ref.getName());
   IWorkspace workspace = ResourcesPlugin.getWorkspace();
   if (fIsPreDeltaTest) {
     IResourceChangeListener listener =
         new IResourceChangeListener() {
           public void resourceChanged(IResourceChangeEvent event) {
             if (create.getConditionCheckingStatus().isOK() && perform.changeExecuted()) {
               TestModelProvider.assertTrue(event.getDelta());
             }
           }
         };
     try {
       TestModelProvider.clearDelta();
       workspace.checkpoint(false);
       workspace.addResourceChangeListener(listener);
       executePerformOperation(perform, workspace);
     } finally {
       workspace.removeResourceChangeListener(listener);
     }
   } else {
     executePerformOperation(perform, workspace);
   }
   RefactoringStatus status = create.getConditionCheckingStatus();
   if (!status.isOK()) return status;
   assertTrue("Change wasn't executed", perform.changeExecuted());
   Change undo = perform.getUndoChange();
   if (providesUndo) {
     assertNotNull("Undo doesn't exist", undo);
     assertTrue("Undo manager is empty", undoManager.anythingToUndo());
   } else {
     assertNull("Undo manager contains undo but shouldn't", undo);
   }
   return null;
 }