public void testMoveProjectWithVirtualFolder() {
    IPath fileLocation = getRandomLocation();
    IPath folderLocation = getRandomLocation();

    IFile file = existingVirtualFolderInExistingProject.getFile(getUniqueString());
    IFolder folder = existingVirtualFolderInExistingProject.getFolder(getUniqueString());
    IFile childFile = folder.getFile(getUniqueString());
    IResource[] oldResources = new IResource[] {existingProject, file, folder, childFile};

    try {
      assertDoesNotExistInWorkspace("1.0", new IResource[] {folder, file, childFile});

      try {
        createFileInFileSystem(fileLocation);
        folderLocation.toFile().mkdir();

        folder.createLink(folderLocation, IResource.NONE, getMonitor());
        file.createLink(fileLocation, IResource.NONE, getMonitor());

        childFile.create(getRandomContents(), true, getMonitor());
      } catch (CoreException e) {
        fail("2.0", e);
      }

      // move the project
      IProject destinationProject = getWorkspace().getRoot().getProject("MoveTargetProject");
      assertDoesNotExistInWorkspace("3.0", destinationProject);

      try {
        existingProject.move(destinationProject.getFullPath(), IResource.SHALLOW, getMonitor());
      } catch (CoreException e) {
        fail("4.0", e);
      }

      IFile newFile = destinationProject.getFile(file.getProjectRelativePath());
      IFolder newFolder = destinationProject.getFolder(folder.getProjectRelativePath());
      IFile newChildFile = newFolder.getFile(childFile.getName());
      IResource[] newResources =
          new IResource[] {destinationProject, newFile, newFolder, newChildFile};

      assertExistsInWorkspace("5.0", newResources);
      assertDoesNotExistInWorkspace("6.1", oldResources);
      assertTrue("7.0", existingProject.isSynchronized(IResource.DEPTH_INFINITE));
      assertTrue("8.0", destinationProject.isSynchronized(IResource.DEPTH_INFINITE));

      assertTrue("9.0", newFile.getParent().isVirtual());
      assertTrue("10.0", newFile.isLinked());

      assertTrue("11.0", newFolder.isLinked());
      assertTrue("12.0", newFolder.getParent().isVirtual());
    } finally {
      Workspace.clear(fileLocation.toFile());
      Workspace.clear(folderLocation.toFile());
    }
  }
  @Before
  public void setUp() throws Exception {

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    FileUtils.mkdir(new File(root.getLocation().toFile(), "Sub"), true);
    gitDir = new File(new File(root.getLocation().toFile(), "Sub"), Constants.DOT_GIT);

    repository = FileRepositoryBuilder.create(gitDir);
    repository.create();

    project = root.getProject(TEST_PROJECT);
    project.create(null);
    project.open(null);
    IProjectDescription description = project.getDescription();
    description.setLocation(root.getLocation().append(TEST_PROJECT_LOC));
    project.move(description, IResource.FORCE, null);

    project2 = root.getProject(TEST_PROJECT2);
    project2.create(null);
    project2.open(null);
    gitDir2 = new File(project2.getLocation().toFile().getAbsoluteFile(), Constants.DOT_GIT);
    repository2 = FileRepositoryBuilder.create(gitDir2);
    repository2.create();

    RepositoryMapping mapping = RepositoryMapping.create(project, gitDir);
    RepositoryMapping mapping2 = RepositoryMapping.create(project2, gitDir2);

    GitProjectData projectData = new GitProjectData(project);
    GitProjectData projectData2 = new GitProjectData(project2);
    projectData.setRepositoryMappings(Collections.singletonList(mapping));
    projectData.store();
    projectData2.setRepositoryMappings(Collections.singletonList(mapping2));
    projectData2.store();
    GitProjectData.add(project, projectData);
    GitProjectData.add(project2, projectData2);

    RepositoryProvider.map(project, GitProvider.class.getName());
    RepositoryProvider.map(project2, GitProvider.class.getName());

    JGitTestUtil.write(
        new File(repository.getWorkTree(), TEST_PROJECT + "/" + TEST_FILE), "Some data");
    JGitTestUtil.write(new File(repository2.getWorkTree(), TEST_FILE2), "Some other data");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    project2.refreshLocal(IResource.DEPTH_INFINITE, null);
    git = new Git(repository);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();

    git = new Git(repository2);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();
    git.branchRename().setNewName("main").call();
  }
  /**
   * Move the project structure to the location provided by user. Also configure JDK, server, server
   * application and key features like session affinity, caching, debugging if user wants to do so.
   *
   * @param projName : Name of the project
   * @param projLocation : Location of the project
   * @param isDefault : whether location of project is default
   * @param selWorkingSets
   * @param workingSetManager
   * @param depMap : stores configurations done on WATagPage
   * @param ftrMap : stores configurations done on WAKeyFeaturesPage
   * @param selProj
   */
  private void doFinish(
      String projName,
      String projLocation,
      boolean isDefault,
      IWorkingSet[] selWorkingSets,
      IWorkingSetManager workingSetManager,
      Map<String, String> depMap,
      Map<String, Boolean> ftrMap,
      IProject selProj) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject project = null;
    try {
      WindowsAzureRole role = waProjMgr.getRoles().get(0);
      // logic for handling deploy page components and their values.
      if (!depMap.isEmpty()) {
        File templateFile = new File(depMap.get("tempFile"));
        role = WizardUtilMethods.configureJDKServer(role, depMap);
        /*
         * Handling adding server application
         * without configuring server/JDK.
         * Always add cloud attributes as
         * approot directory is not created yet
         * hence all applications are
         * imported from outside of the Azure project
         */
        if (!tabPg.getAppsAsNames().isEmpty()) {
          for (int i = 0; i < tabPg.getAppsList().size(); i++) {
            AppCmpntParam app = tabPg.getAppsList().get(i);
            if (!app.getImpAs().equalsIgnoreCase(Messages.helloWorld)) {
              role.addServerApplication(
                  app.getImpSrc(), app.getImpAs(), app.getImpMethod(), templateFile, true);
            }
          }
        }
      }

      /** Handling for HelloWorld application in plug-in */
      if (tabPg != null) {
        if (!tabPg.getAppsAsNames().contains(Messages.helloWorld)) {
          List<WindowsAzureRoleComponent> waCompList =
              waProjMgr.getRoles().get(0).getServerApplications();
          for (WindowsAzureRoleComponent waComp : waCompList) {
            if (waComp.getDeployName().equalsIgnoreCase(Messages.helloWorld)
                && waComp.getImportPath().isEmpty()) {
              waComp.delete();
            }
          }
        }
      }
      role = WizardUtilMethods.configureKeyFeatures(role, ftrMap);

      waProjMgr.save();
      WindowsAzureProjectManager.moveProjFromTemp(projName, projLocation);
      String launchFilePath = projLocation + File.separator + projName + LAUNCH_FILE_PATH;
      ParseXML.setProjectNameinLaunch(launchFilePath, Messages.pWizWinAzureProj, projName);

      root.touch(null);
      project = root.getProject(projName);
      IProjectDescription projDescription = workspace.newProjectDescription(projName);

      Path path = new Path(projLocation + File.separator + projName);
      projDescription.setLocation(path);
      projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID});

      if (!project.exists()) {
        if (isDefault) {
          project.create(null);
        } else {
          project.create(projDescription, null);
        }
      }
      project.open(null);

      projDescription = project.getDescription();
      projDescription.setName(projName);
      projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID});

      project.move(projDescription, IResource.FORCE, null);

      workingSetManager.addToWorkingSets(project, selWorkingSets);

      root.touch(null);
      if (project != null) {
        WADependencyBuilder builder = new WADependencyBuilder();
        builder.addBuilder(project, "com.persistent.winazure.eclipseplugin.Builder");
      }
    } catch (Exception e) {
      Display.getDefault()
          .syncExec(
              new Runnable() {
                public void run() {
                  MessageDialog.openError(null, Messages.pWizErrTitle, Messages.pWizErrMsg);
                }
              });
      Activator.getDefault().log(Messages.pWizErrMsg, e);
    }
  }