private void findSelectEnterpriseRuntimeLibrary(SWTBotExt bot) throws Exception { SWTBotTree libraryTree = bot.tree(1); boolean libraryFound = false; for (SWTBotTreeItem libraryItem : libraryTree.getAllItems()) { if (libraryItem.getText().contains("JBoss Enterprise Application Platform")) { libraryTree.select(libraryItem); libraryFound = true; break; } } if (!libraryFound) throw new RuntimeException("No runtime library has been found"); }
public static void setectTreeNode(SWTBotTree tree) { tree.select(0); }
@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 testPushToOrigin(boolean useRemote) throws Exception { Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile); shareProjects(clonedRepositoryFile); Repository repository = lookupRepository(clonedRepositoryFile); // add the configuration for push repository .getConfig() .setString("remote", "origin", "push", "refs/heads/*:refs/remotes/origin/*"); repository.getConfig().save(); // make sure to have a "new" branch name so that the // dialog will return with a corresponding message String currentBranch = repository.getBranch(); new Git(repository) .branchRename() .setOldName(currentBranch) .setNewName("" + System.currentTimeMillis()) .call(); SWTBotTree tree = getOrOpenView().bot().tree(); tree.select(0); TestUtil.waitForJobs(50, 5000); selectNode(tree, useRemote, false); runPush(tree); String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin"; String dialogTitle = NLS.bind(UIText.PushResultDialog_title, destinationString); // first time: expect new branch SWTBotShell confirmed = bot.shell(dialogTitle); SWTBotTreeItem[] treeItems = confirmed.bot().tree().getAllItems(); boolean newBranch = false; for (SWTBotTreeItem item : treeItems) { newBranch = item.getText().contains(UIText.PushResultTable_statusOkNewBranch); if (newBranch) break; } confirmed.close(); assertTrue("New branch expected", newBranch); // second time: expect up to date selectNode(tree, useRemote, false); runPush(tree); confirmed = bot.shell(dialogTitle); treeItems = confirmed.bot().tree().getAllItems(); boolean uptodate = false; for (SWTBotTreeItem item : treeItems) { uptodate = item.getText().contains(UIText.PushResultTable_statusUpToDate); if (uptodate) break; } confirmed.close(); assertTrue("Up to date expected", uptodate); // touch and run again: expect new branch String objectIdBefore = repository.getRef(repository.getFullBranch()).getLeaf().getObjectId().name(); objectIdBefore = objectIdBefore.substring(0, 7); touchAndSubmit(null); SWTBotTree updatedTree = getOrOpenView().bot().tree(); updatedTree.select(0); selectNode(updatedTree, useRemote, false); runPush(updatedTree); confirmed = bot.shell(dialogTitle); treeItems = confirmed.bot().tree().getAllItems(); newBranch = false; for (SWTBotTreeItem item : treeItems) { newBranch = item.getText().contains(objectIdBefore); if (newBranch) break; } confirmed.close(); assertTrue("New branch expected", newBranch); }