@After
  public void canDeleteEWSApp() {
    SWTBotView openshiftExplorer = open.viewOpen(OpenShiftUI.Explorer.iView);

    SWTBotTreeItem account =
        openshiftExplorer.bot().tree().getAllItems()[0].doubleClick(); // expand account

    bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S);

    account
        .getNode(EWS_APP_NAME + " " + OpenShiftUI.AppType.JBOSS_EWS)
        .contextMenu(OpenShiftUI.Labels.EXPLORER_DELETE_APP)
        .click();

    bot.waitForShell(OpenShiftUI.Shell.DELETE_APP);

    bot.button(IDELabel.Button.OK).click();
    bot.waitWhile(new NonSystemJobRunsCondition(), TIME_60S * 2, TIME_1S);

    assertTrue(
        "Application still present in the OpenShift Explorer!", account.getItems().length == 0);

    projectExplorer.show();
    projectExplorer.deleteAllProjects();

    assertFalse("The project still exists!", bot.tree().getAllItems().length > 0);

    servers.show();
    servers.deleteServer(EWS_APP_NAME + " at OpenShift");
  }
Esempio n. 2
0
 /**
  * First level should have 5 children
  *
  * @throws Exception
  */
 @Test
 public void testExpandFirstLevel() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile).expand();
   SWTBotTreeItem[] children = item.getItems();
   assertEquals("Wrong number of children", 5, children.length);
 }
  @Test
  public void shouldNotShowIgnoredFiles() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    String ignoredName = "to-be-ignored.txt";

    IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);

    IFile ignoredFile = proj.getFile(ignoredName);
    ignoredFile.create(
        new ByteArrayInputStream("content of ignored file".getBytes(proj.getDefaultCharset())),
        false,
        null);

    IFile gitignore = proj.getFile(".gitignore");
    gitignore.create(
        new ByteArrayInputStream(ignoredName.getBytes(proj.getDefaultCharset())), false, null);
    proj.refreshLocal(IResource.DEPTH_INFINITE, null);

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, PROJ1);
    projectTree.expand();
    assertEquals(1, projectTree.getItems().length);
  }
 @Override
 public boolean test() throws Exception {
   fParentItem.expand();
   for (SWTBotTreeItem item : fParentItem.getItems()) {
     if (item.getText().matches(fRegex)) {
       fItem = item;
       return true;
     }
   }
   return false;
 }
  @Test
  public void testDeleteTag() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().rowCount();

    createTag("Delete1", "The first tag");
    refreshAndWait();
    SWTBotTreeItem tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    SWTBotTreeItem[] items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount + 1, items.length);
    tagsItem.select("Delete1");
    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("DeleteTagCommand.name"));
    bot.shell(UIText.DeleteTagCommand_titleConfirm).bot().button(IDialogConstants.OK_LABEL).click();
    TestUtil.joinJobs(JobFamilies.TAG);
    refreshAndWait();
    tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount, items.length);
  }
  @Test
  public void shouldSynchronizeInEmptyRepository() throws Exception {
    // given
    createEmptyRepository();

    // when
    launchSynchronization(EMPTY_PROJECT, "", "", true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, EMPTY_PROJECT);
    assertEquals(1, syncViewTree.getAllItems().length);

    SWTBotTreeItem folderTree = waitForNodeWithText(projectTree, FOLDER);
    assertEquals(2, folderTree.getItems().length);

    SWTBotTreeItem fileTree = folderTree.getItems()[0];
    assertEquals(FILE1, fileTree.getText());
    fileTree = folderTree.getItems()[1];
    assertEquals(FILE2, fileTree.getText());
  }
  @Test
  public void shouldListFileDeletedChange() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    deleteFileAndCommit(PROJ1);

    // when
    launchSynchronization(HEAD, INITIAL_TAG, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    assertEquals(1, syncViewTree.getAllItems().length);

    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, PROJ1);
    assertEquals(1, projectTree.getItems().length);

    SWTBotTreeItem folderTree = waitForNodeWithText(projectTree, FOLDER);
    assertEquals(1, folderTree.getItems().length);

    SWTBotTreeItem fileTree = folderTree.getItems()[0];
    assertEquals("test.txt", fileTree.getText());
  }
  /**
   * Remove Project from all Servers
   *
   * @param projectName
   * @param stringToContain
   */
  public void removeProjectFromServers(String projectName, String stringToContain) {

    eclipse.showView(ViewType.SERVERS);

    delay();

    try {
      SWTBotTree serverTree = bot.viewByTitle(IDELabel.View.SERVERS).bot().tree();

      delay();

      // Expand All
      for (SWTBotTreeItem serverTreeItem : serverTree.getAllItems()) {
        serverTreeItem.expand();
        // if JSF Test Project is deployed to server remove it
        SWTBotTreeItem[] serverTreeItemChildren = serverTreeItem.getItems();
        if (serverTreeItemChildren != null && serverTreeItemChildren.length > 0) {
          int itemIndex = 0;
          boolean found = false;
          String treeItemlabel = null;
          do {
            treeItemlabel = serverTreeItemChildren[itemIndex].getText();
            found =
                treeItemlabel.startsWith(projectName)
                    && (stringToContain == null || treeItemlabel.indexOf(stringToContain) >= 0);
          } while (!found && ++itemIndex < serverTreeItemChildren.length);
          // Server Tree Item has Child with Text equal to JSF TEst Project
          if (found) {
            log.info("Found project to be removed from server: " + treeItemlabel);
            ContextMenuHelper.prepareTreeItemForContextMenu(
                serverTree, serverTreeItemChildren[itemIndex]);
            new SWTBotMenu(
                    ContextMenuHelper.getContextMenu(serverTree, IDELabel.Menu.REMOVE, false))
                .click();
            bot.shell("Server").activate();
            bot.button(IDELabel.Button.OK).click();
            log.info("Removed project from server: " + treeItemlabel);
            bot.sleep(10 * 1000L);
          }
        }
      }
      delay();

    } catch (WidgetNotFoundException wnfe) {
      // do nothing it means there is no server defined
    }
  }
  @Test
  public void testCreateTags() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().rowCount();

    String initialObjid = getObjectIdOfCommit();
    createTag("FirstTag", "The first tag");
    touchAndSubmit(null);
    String newObject = getObjectIdOfCommit();
    createTag("SecondTag", "The second tag");
    refreshAndWait();
    SWTBotTreeItem tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    SWTBotTreeItem[] items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount + 2, items.length);

    assertTrue("Wrong commit id", initialObjid.equals(getCommitIdOfTag("FirstTag")));
    assertTrue("Wrong commit id", newObject.equals(getCommitIdOfTag("SecondTag")));
  }
  /**
   * Checks IU (Category, or Feature) in a tree
   *
   * @param iu to be checked
   * @return true if checked
   * @author Pavol Srna
   */
  private boolean checkIU(String iu) {

    boolean checked = false;
    for (SWTBotTreeItem node : bot.tree().getAllItems()) {
      // traverse through all categories
      if (node.getText().equals(iu)) {
        node.check();
        checked = true;
        break;
      } else {
        // expand category
        node.expand();
        for (SWTBotTreeItem i : node.getItems()) {
          // traverse through category features
          if (i.getText().equals(iu)) {
            i.check();
            checked = true;
            break;
          }
        }
      }
    }
    return checked;
  }
  @Test
  public void testServerBuild() {

    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor activeEditor = bot.activeEditor();
    final String editorTitle = activeEditor.getTitle();
    // System.out.println("editorTitle1 = "+editorTitle1);
    assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty());

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();
    new BotGefProcessDiagramEditor(bot).selectElement("Step1");
    new BotExecutionDiagramPropertiesView(bot).selectFormTab().selectLegacy();

    // get the GEF editor to activate tools
    final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle);

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    // Save Diagram
    bot.menu("Diagram").menu("Save").click();

    // System.out.println(editorTitle);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Server")));

    // Menu Server > Build...
    bot.menu("Server").menu("Build...").click();

    // shell 'Build'
    final SWTBotShell shell = bot.shell(Messages.buildTitle);
    bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle));

    // select and check created Diagram in the Tree
    final SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

    // check the diagram to export
    diagramTreeItem.select().check();
    diagramTreeItem.expand();

    // Number of pool in the diagram
    final int poolListSize = diagramTreeItem.getItems().length;
    // System.out.println("Diagram contains "+ poolListSize + " items");
    assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize);

    // unselect the first pool of the list

    diagramTreeItem.getNode(0).select();
    diagramTreeItem.getNode(0).uncheck();

    final Vector<String> poolTitleList = new Vector<String>(3);
    final int poolTitleListSize = poolTitleList.size();

    // check the selected pools
    for (int i = 1; i < poolTitleListSize; i++) {
      final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i);
      poolTitleList.set(i, poolTreeItem.getText());
      final String poolName = getItemName(poolTitleList.get(i));

      // test the good pool is checked
      assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
      assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar");
    tmpBarFolder.mkdirs();
    // set the path where files are saved
    final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath();
    bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath);
    //		String tmpBarFolderPath = bot.comboBoxWithLabel(Messages.destinationPath+" *").getText();
    //		System.out.println("tmpBarFolder = "+tmpBarFolderPath);

    // click 'Finish' button to close 'Build' shell
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    //  click 'OK' button to close 'Export' shell
    bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    // wait the shell to close before checking creation of files
    bot.waitUntil(Conditions.shellCloses(shell));

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
      final String tmpPoolTitle = poolTitleList.get(i);
      final String poolFileName =
          getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar";
      final File poolFile = new File(tmpBarFolderPath, poolFileName);

      assertTrue("Error: The Pool export must exist", poolFile.exists());
      assertTrue("Error: The Pool export must be a file", poolFile.isFile());
    }
  }