示例#1
0
  /**
   * Add and set a new variable in the data entry of the General tab of a Task
   *
   * @param varName name of the variable
   * @param varType type of the variable : "Text", "Integer", "String", "Boolean", etc...
   * @param autoGenerateForm BOS-SP only : true if the checkBox must be selected, else false
   */
  private void setNewVariablewithdefault(
      final SWTGefBot bot,
      final String varName,
      final String varType,
      final boolean autoGenerateForm,
      final String defname,
      final String script,
      final String returntype) {
    bot.button("Add...").click();

    // open shell "New variable"
    bot.waitUntil(Conditions.shellIsActive(newVariable));

    // "Name"
    bot.textWithLabel(name).setText(varName);

    // "Data type"
    bot.comboBoxWithLabel(datatypeLabel).setSelection(varType);

    if (SWTBotTestUtil.testingBosSp()) {
      final SWTBotCheckBox cb = bot.checkBox("Auto-generate form");
      if (cb.isChecked() && !autoGenerateForm) {
        cb.deselect();
      } else if (!cb.isChecked() && autoGenerateForm) {
        cb.select();
      }
    }

    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, defname, script, returntype);
    bot.waitUntil(Conditions.shellIsActive(newVariable));

    bot.button(IDialogConstants.FINISH_LABEL).click();
  }
示例#2
0
  /**
   * @param scriptName
   * @param expression
   * @param returnTypeOfScript
   */
  public static void setScriptExpression1(
      final SWTGefBot bot, final String scriptName, final String expression) {
    bot.waitUntil(Conditions.shellIsActive(editExpression));
    bot.tableWithLabel(expressionTypeLabel).select("Script");
    bot.sleep(1000);
    // set the Script name
    bot.textWithLabel("Name *").setText(scriptName);
    bot.styledText().setText(expression);

    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)));
    bot.button(IDialogConstants.OK_LABEL).click();
  }
示例#3
0
  /**
   * Add and set a new variable in the data entry of the General tab of a Task
   *
   * @param varName name of the variable
   * @param varType type of the variable : "Text", "Integer", "String", "Boolean", etc...
   * @param autoGenerateForm BOS-SP only : true if the checkBox must be selected, else false
   */
  private void setNewVariable(
      final SWTGefBot bot,
      final String varName,
      final String varType,
      final boolean autoGenerateForm) {
    bot.button("Add...").click();

    // open shell "New variable"
    bot.waitUntil(Conditions.shellIsActive(newVariable));

    // "Name"
    bot.textWithLabel(name).setText(varName);

    // "Data type"
    bot.comboBoxWithLabel(datatypeLabel).setSelection(varType);

    if (SWTBotTestUtil.testingBosSp()) {
      final SWTBotCheckBox cb = bot.checkBox("Auto-generate form");
      if (cb.isChecked() && !autoGenerateForm) {
        cb.deselect();
      } else if (!cb.isChecked() && autoGenerateForm) {
        cb.select();
      }
    }

    bot.button(IDialogConstants.FINISH_LABEL).click();
  }
示例#4
0
  /**
   * @param dataName
   * @param defaultValue
   * @param classType
   */
  public void addJavaObjectData(
      final SWTGefBot bot, final String dataName, final String classType) {

    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();

    // DATA
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");

    // Add a new variable
    bot.button(addData).click();
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.shell(newVariable);

    // set global value
    bot.sleep(10000);

    bot.waitUntilWidgetAppears(Conditions.widgetIsEnabled(bot.textWithLabel(name)));
    bot.textWithLabel(name).setText(dataName);
    bot.comboBoxWithLabel(datatypeLabel).setSelection("Java Object");
    bot.textWithLabel(classLabel).setText(classType);
  }
示例#5
0
  /**
   * Create a new Form and save it
   *
   * @param bot
   * @param gmfEditor
   * @param nameOfStepOnwhichCreateTheForm
   * @return
   */
  public static SWTBotEditor createFormWhenOnAProcessWithStep1(
      final SWTGefBot bot,
      final SWTBotGefEditor gmfEditor,
      final String nameOfStepOnwhichCreateTheForm) {
    final SWTBotGefEditPart part = gmfEditor.getEditPart(nameOfStepOnwhichCreateTheForm);
    if (part != null) {
      System.out.println("wow part is not null" + part.toString());
    } else {
      System.out.println("part is null");
    }

    try {
      System.out.println(
          "tosting is:"
              + part.toString()
              + "source size is:"
              + part.sourceConnections().size()
              + "target size is:"
              + part.targetConnections().size()
              + "parent"
              + part.parent().toString());
    } catch (final Exception e) {
      System.out.println("Exception is:" + e.getMessage());
    }

    part.click();

    // part.focus();

    bot.viewById("org.bonitasoft.studio.views.properties.application").show();
    bot.viewById("org.bonitasoft.studio.views.properties.application").setFocus();

    SWTBotTestUtil.selectTabbedPropertyView(bot, "Pageflow");
    final SWTBotView properties = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_APPLICATION);
    properties.bot().button("Add...").click();
    bot.waitUntil(Conditions.shellIsActive("Add form..."));
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.button("Unselect all").click();

    bot.button(IDialogConstants.FINISH_LABEL).click();
    final SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.save();
    return activeEditor;
  }
示例#6
0
  public static void addemailconnector(
      final SWTGefBot bot,
      final String name,
      final String from,
      final String to,
      final String subject,
      final String content) {
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Connectors");
    bot.button("Add...").click();
    bot.waitUntil(Conditions.shellIsActive("Connectors"));

    bot.tree().setFocus();
    final SWTBotTreeItem wss = bot.tree().getTreeItem("Messaging").expand();

    String emailNode = null;
    for (final String child : wss.getNodes()) {

      if (child.contains("Email")) {
        emailNode = child;
      }
    }
    wss.getNode(emailNode).select();
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.textWithLabel("Name *").setText(name);
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 0).setText(from);
    bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 1).setText(to);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.NEXT_LABEL)));
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "subject", subject, null);

    // bot.button(IDialogConstants.OK_LABEL).click();

    bot.styledText().setText(content);

    /*bot.sleep(2000);
       bot.link(0).click();
       bot.sleep(2000);
       bot.button("Yes").click();
       bot.sleep(2000);

       bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();
       SWTBotTestUtil.setScriptExpression( bot,  "body",  content,  null );
    */

    bot.sleep(5000);

    bot.button(IDialogConstants.NEXT_LABEL).click();
    bot.button(IDialogConstants.FINISH_LABEL).click();

    bot.activeEditor().save();
    // DiagramEditPart dpart = (DiagramEditPart)
    // bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart().part();
    // MainProcess proc = (MainProcess) dpart.resolveSemanticElement();
    // List<Connector> connectors = ModelHelper.getAllItemsOfType(proc,
    // ProcessPackage.Literals.CONNECTOR);
    /*	for(Connector c : connectors){
    		if(c.getDefinitionId().equals("email")){
    			for(ConnectorParameter p : c.getConfiguration().getParameters()){
    				if("message".equals(p.getKey())){


    					String htmlContent = ((Expression) p.getExpression()).getContent();
    					assertEquals("Invalid html content", HTML_CONTENT, htmlContent.replaceAll(" ","").replaceAll("\\s",""));
    				}
    			}

    }*/

  }
  @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());
    }
  }
  @Test
  public void testDeleteDiagrams() {

    final DiagramRepositoryStore diagramStore =
        RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);

    final int nbDiagramsInRepository = diagramStore.getChildren().size();

    final SWTBotMenu diagramMenu = bot.menu("Diagram");
    final List<String> newDiagramsName = new ArrayList<String>();
    for (int i = 0; i < nbDiagrams; i++) {
      SWTBotTestUtil.createNewDiagram(bot);
      bot.waitUntil(Conditions.widgetIsEnabled(diagramMenu), 40000);
      newDiagramsName.add(bot.activeEditor().getTitle());
    }
    assertEquals("4 diagrams should have been created", nbDiagrams, newDiagramsName.size());

    final int nbEditors = bot.editors().size();
    final String currentDiagramName = bot.activeEditor().getTitle();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Diagram")), 10000);
    bot.menu("Diagram").menu("Delete...").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.DeleteDiagramWizardPage_title), 10000);

    final SWTBotTree tree = bot.tree();
    assertEquals(
        "the list of diagrams should contain 4 items",
        nbDiagramsInRepository + nbDiagrams,
        tree.getAllItems().length);

    final TableCollection selection = tree.selection();
    assertEquals(
        "only " + currentDiagramName + " should be selected in the tree viewer",
        1,
        selection.rowCount());
    assertEquals(
        "diagram " + currentDiagramName + " should be selected",
        currentDiagramName,
        selection.get(0, 0));

    //   final SWTBotTreeItem firstSwtBotTreeItem = tree.getAllItems()[1];
    //   final SWTBotTreeItem secondSwtBotTreeItem = tree.getAllItems()[2];
    //   final SWTBotTreeItem thirdSwtBotTreeItem = tree.getAllItems()[3];

    tree.select(newDiagramsName.get(1), newDiagramsName.get(2), newDiagramsName.get(3));

    bot.button(Messages.removeProcessLabel).click();

    bot.waitUntil(Conditions.shellIsActive(Messages.confirmProcessDeleteTitle));
    bot.button(IDialogConstants.YES_LABEL).click();
    bot.waitUntil(
        new ICondition() {

          @Override
          public boolean test() throws Exception {
            return nbEditors - 3 == bot.editors().size();
          }

          @Override
          public void init(final SWTBot bot) {}

          @Override
          public String getFailureMessage() {
            return "editors have not been closed after deleted diagrams";
          }
        },
        40000,
        100);

    assertEquals(
        "deleted diagrams are still in repository",
        nbDiagramsInRepository + 1,
        diagramStore.getChildren().size());
  }
 private void waitForTable() {
   bot.waitUntil(Conditions.widgetIsEnabled(iteratorEditor()));
 }