private void finalEvent( final SWTGefBot bot, final SWTBotGefEditor gmfEditor, final String source) { gmfEditor.activateTool("End"); final Point targetLocation = SWTBotTestUtil.computeTargetLocation(gmfEditor, source, PositionConstants.SOUTH); gmfEditor.click(targetLocation.x, targetLocation.y); SWTBotTestUtil.addSequenceFlow(bot, gmfEditor, source, "End1", PositionConstants.WEST); // SWTBotTestUtil.configureSequenceFlow(bot,"sequenceFlow4","Web Purchase", false, null, // ExpressionConstants.VARIABLE_TYPE); }
public void appendActivity(SWTBotGefEditPart toPart, String activity, String name) { setFocus(toPart); gEditor.clickContextMenu("Add").clickContextMenu(activity); propsView.selectTab(0); SWTBot propsBot = propsView.bot(); propsBot.text(0).setText(name); }
public static void increaseLaneHeight(final SWTBotGefEditor editor, final String laneName) { final SWTBotGefEditPart lanePart = editor.getEditPart(laneName).parent(); lanePart.select(); final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) lanePart.part(); final UpdateSizePoolSelectionEditPolicy addPoolSizeElementEditPolicy = (UpdateSizePoolSelectionEditPolicy) graphicalEditPart.getEditPolicy( UpdateSizePoolSelectionEditPolicy.UPDATE_POOL_SIZE_SELECTION_FEEDBACK_ROLE); final IFigure toolbarFigure = addPoolSizeElementEditPolicy.getFigure(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM); final Point location = toolbarFigure.getBounds().getCenter().getCopy(); toolbarFigure.translateToAbsolute(location); editor.click(location.x, location.y); }
public SWTBotGefEditPart addPickOnMessage( SWTBotGefEditPart pickPart, String in, String[] operationInfo) { setFocus(pickPart); gEditor.clickContextMenu("Add OnMessage"); save(); // get the new ElseIfPart List<SWTBotGefEditPart> children = pickPart.children(); SWTBotGefEditPart onMessagePart = children.get(children.size() - 1); // test the part if (!(onMessagePart.part().getModel() instanceof OnMessage)) { onMessagePart = children.get(children.size() - 2); } setFocus(onMessagePart); propsView.selectTab(0); SWTBot propsBot = propsView.bot(); propsBot.tree().expandNode(operationInfo).select(); propsBot.text(2).setText(in); save(); log.info("Added [part=" + onMessagePart + ", name=Unnamed]"); return onMessagePart; }
@Test public void testConditionExpressions() throws IOException, InterruptedException { SWTBotTestUtil.importProcessWIthPathFromClass( bot, "TestDecisionTable-1.0.bos", SWTBotTestUtil.IMPORTER_TITLE_BONITA, "TestDecisionTable", getClass(), false); final SWTBotEditor botEditor = bot.activeEditor(); final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle()); gmfEditor.getEditPart("sf1").click(); bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show(); SWTBotTestUtil.selectTabbedPropertyView(bot, "General"); bot.radio(useDecisionTable).click(); bot.waitUntil(Conditions.widgetIsEnabled(bot.button(editDecisionTable))); bot.button(editDecisionTable).click(); bot.waitUntil(Conditions.shellIsActive(Messages.wizardPageTitle)); bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addRow + "</A>"))); bot.link("<A>" + Messages.addRow + "</A>").click(Messages.addRow); bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addCondition + "</A>"))); addTrueCondition(0, "true"); addTrueCondition(1, "1==2"); addFalseCondition(2, "sdkgjskrg"); changeCondition(2, "myBoolean"); testUpdateLineButtonEnabled(); bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_ERASEBUTTON, 0).click(); bot.sleep(1000); testUpdateLineButtonNotEnabled(); changeCondition(0, "myText==\"\""); testUpdateLineButtonEnabled(); bot.button(Messages.updateLine).click(); bot.button(IDialogConstants.FINISH_LABEL); SWTBotTestUtil.waitUntilBonitaBPmShellIsActive(bot); bot.saveAllEditors(); }
// TODO: add properties and test public SWTBotGefEditPart addFaultHandler(SWTBotGefEditPart part) { setFocus(part); gEditor.clickContextMenu("Add Fault Handler"); save(); printChildren(part); return null; }
/** * TODO: Change the implementation of this method. At the moment this method expects a concrete * order of child elements !!! * * @param ifPart * @return */ public SWTBotGefEditPart addElse(SWTBotGefEditPart ifPart) { setFocus(ifPart); gEditor.clickContextMenu("Add Else"); save(); // get ElsePart List<SWTBotGefEditPart> children = ifPart.children(); SWTBotGefEditPart added = children.get(children.size() - 1); log.info("Added [part=" + added + ", name=Unnamed]"); return added; }
/** * Change the type of a Task to be 'Human' * * @param gmfEditor * @param nameTask name of the Task */ private void setTaskAsHuman( final SWTGefBot bot, final SWTBotGefEditor gmfEditor, final String nameTask) { gmfEditor.getEditPart(nameTask).click(); // set the Task as Human Task bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show(); SWTBotTestUtil.selectTabbedPropertyView(bot, "General"); // "Task type" , "Human" bot.comboBoxWithLabel(activityType).setSelection(activityType_task); }
public static void movepositions( final SWTGefBot bot, SWTBotGefEditor gmfEditor, final String sourcelane, final String destlane, final String element, final int j, final int i) { final SWTBotEditor botEditor = bot.activeEditor(); gmfEditor = bot.gefEditor(botEditor.getTitle()); final SWTBotGefEditPart lane2 = gmfEditor.getEditPart(sourcelane); lane2.parent().select().resize(PositionConstants.NORTH, 100, 150); // compute target destination final SWTBotGefEditPart lane3 = gmfEditor.getEditPart(destlane); // move step2 to lane2 final SWTBotGefEditPart ele = gmfEditor.getEditPart(element).parent(); ele.select(); // move step2 to lane2 SWTBotGefEditPart step = gmfEditor.getEditPart(element).parent(); step.select(); IFigure figure = ((GraphicalEditPart) step.part()).getFigure(); final Rectangle dest = figure.getBounds().getCopy(); figure.translateToAbsolute(dest); gmfEditor.drag(step, dest.x + j, dest.y + i); step = gmfEditor.getEditPart(element).parent(); step.select(); figure = ((GraphicalEditPart) step.part()).getFigure(); final Rectangle targetdest = figure.getBounds().getCopy(); figure.translateToAbsolute(targetdest); Assert.assertTrue("Move has failed", !targetdest.equals(dest)); bot.waitUntil( new ICondition() { @Override public boolean test() throws Exception { return getPartRecursively(lane3.parent(), element) != null; } @Override public void init(final SWTBot bot) {} @Override public String getFailureMessage() { System.out.println(element + "is not in sourcelane"); return "element is not in sourcelane (unable to move the step)"; } }); }
/** * 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; }
// DONE ! public SWTBotGefEditPart addPick(SWTBotGefEditPart toPart, String name, boolean createInstance) { appendActivity(toPart, "Pick", name); SWTBot propsBot = propsView.bot(); propsView.selectTab(1); if (createInstance) { propsBot.checkBox().select(); } SWTBotGefEditPart pickPart = getEditPart(toPart, name); SWTBotGefEditPart onMessagePart = pickPart.children().get(0); setFocus(onMessagePart); // remove OnMessage branch to make the methods coherent gEditor.clickContextMenu("Delete"); setFocus(pickPart); save(); log.info("Added [part=" + pickPart + ", name=" + pickPart + "]"); return pickPart; }
/** * TODO: See {@link #addElse(SWTBotGefEditPart)} * * @param ifPart * @param condition * @return * @throws Exception */ public SWTBotGefEditPart addElseIf(SWTBotGefEditPart ifPart, String condition) throws Exception { setFocus(ifPart); gEditor.clickContextMenu("Add ElseIf"); // get the new ElseIfPart List<SWTBotGefEditPart> children = ifPart.children(); SWTBotGefEditPart elseIfPart = children.get(children.size() - 1); // test the part if (elseIfPart.part().getModel() instanceof ElseImpl) { elseIfPart = children.get(children.size() - 2); } setFocus(elseIfPart); // setup properties propsView.selectTab(0); SWTBot propsBot = propsView.bot(); propsBot.button("Create a New Condition").click(); propsBot.styledText().setText(condition); save(); log.info("Added [part=" + elseIfPart + ", name=Unnamed]"); return elseIfPart; }
public SWTBotGefEditPart addPickOnAlarm(SWTBotGefEditPart pickPart, String expression) { setFocus(pickPart); gEditor.clickContextMenu("Add OnAlarm"); save(); // get the new ElseIfPart List<SWTBotGefEditPart> children = pickPart.children(); SWTBotGefEditPart onAlaramPart = children.get(children.size() - 1); // test the part if (!(onAlaramPart.part().getModel() instanceof OnAlarm)) { onAlaramPart = children.get(children.size() - 2); } setFocus(onAlaramPart); SWTBot propsBot = propsView.bot(); propsBot.button("Create a New Condition").click(); propsBot.comboBox(1).setSelection("Text"); propsBot.styledText().setText(expression); save(); log.info("Added [part=" + onAlaramPart + ", name=Unnamed]"); // if onAlarm contains scope then return the scope. onAlarm otherwise return (onAlaramPart.children().size() == 1) ? onAlaramPart.children().get(0) : onAlaramPart; }
public boolean test() throws Exception { return !(gefEditor.mainEditPart().children().isEmpty()); }
public void setFocus(SWTBotGefEditPart part) { gEditor.setFocus(); part.select(); }
public void save() { gEditor.save(); }
// TODO: - test me // - How to validate this??? public void delete(SWTBotGefEditPart part) { gEditor.setFocus(); part.select(); gEditor.clickContextMenu("Delete"); }
@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()); } }
public SWTBotBPELEditor(SWTBotGefEditor editor, SWTWorkbenchBot bot) { super(editor.getReference(), bot); gEditor = editor; propsView = new SWTBotPropertiesView(bot); propsView.show(); }