@Test
 public void testIdRenameEdit() throws Exception {
   final String id = "testEdit";
   final String version = "1.0.0";
   final String id2 = "testEdit2";
   SWTBotConnectorTestUtil.activateConnectorDefinitionShell(bot);
   SWTBotConnectorTestUtil.createConnectorDefinition(bot, id, version);
   bot.button(IDialogConstants.FINISH_LABEL).click();
   SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
   bot.tree().setFocus();
   bot.waitUntil(
       Conditions.widgetIsEnabled(
           bot.tree()
               .select("Uncategorized")
               .expandNode("Uncategorized")
               .select(id + " (" + version + ")")),
       10000);
   bot.tree().expandNode("Uncategorized").select(id + " (" + version + ")");
   bot.button(Messages.Edit).click();
   assertEquals(bot.textWithLabel("Definition id *").getText(), id);
   assertEquals(bot.textWithLabel("Version *").getText(), version);
   bot.textWithLabel("Definition id *").setText(id2);
   bot.button(IDialogConstants.FINISH_LABEL).click();
   ConnectorDefRepositoryStore store =
       (ConnectorDefRepositoryStore)
           RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class);
   ConnectorDefinition connectorDef = store.getDefinition(id, version);
   ConnectorDefinition connectorDef2 = store.getDefinition(id2, version);
   assertNull("the connectorDef with previous id shouldn't exist anymore", connectorDef);
   assertNotNull("the connectorDef with new id does not exist", connectorDef2);
   removeConnectorDefinition(id2, version);
 }
  @Test
  public void testAddCategory() throws Exception {
    final String id = "testEdit4";
    final String version = "1.0.0";

    SWTBotConnectorTestUtil.activateConnectorDefinitionShell(bot);
    SWTBotConnectorTestUtil.createConnectorDefinition(bot, id, version);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    bot.tree().setFocus();
    bot.waitUntil(
        Conditions.widgetIsEnabled(
            bot.tree().expandNode("Uncategorized").select(id + " (" + version + ")")),
        10000);
    bot.tree()
        .select("Uncategorized")
        .expandNode("Uncategorized")
        .select(id + " (" + version + ")");
    bot.button(Messages.Edit).click();
    bot.treeWithLabel(Messages.categoryLabel).select(0);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    ConnectorDefRepositoryStore store =
        (ConnectorDefRepositoryStore)
            RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class);
    ConnectorDefinition connectorDef = store.getDefinition(id, version);
    assertEquals("category size should be equal to 1", 1, connectorDef.getCategory().size());
    DefinitionResourceProvider messageProvider =
        DefinitionResourceProvider.getInstance(store, ConnectorPlugin.getDefault().getBundle());
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    final Category category = connectorDef.getCategory().get(0);
    String categoryLabel = messageProvider.getCategoryLabel(category);
    if (categoryLabel == null) {
      categoryLabel = category.getId();
    }
    final String connectorLabel =
        new ConnectorDefinitionTreeLabelProvider(messageProvider).getText(connectorDef);
    assertNotNull(
        "could not find " + connectorLabel,
        bot.tree().getTreeItem(categoryLabel).expand().getNode(connectorLabel));
    bot.button(IDialogConstants.CANCEL_LABEL).click();
  }
  public void removeConnectorDefinition(final String name, final String version) {
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    bot.tree().setFocus();
    bot.waitUntil(
        new ICondition() {

          public boolean test() throws Exception {
            bot.tree()
                .select("Uncategorized")
                .expandNode("Uncategorized")
                .select(name + " (" + version + ")");
            return bot.tree().selectionCount() > 0;
          }

          public void init(SWTBot bot) {}

          public String getFailureMessage() {
            return "Cannot select tree item";
          }
        },
        10000,
        1000);

    assertNotNull(
        "could not find" + name + " (" + version + ")",
        bot.tree()
            .select("Uncategorized")
            .expandNode("Uncategorized")
            .getNode(name + " (" + version + ")"));
    bot.tree()
        .select("Uncategorized")
        .expandNode("Uncategorized")
        .select(name + " (" + version + ")");
    bot.button("Delete").click();
    if (!FileActionDialog.getDisablePopup()) {
      bot.waitUntil(Conditions.shellIsActive("Delete?"));
      bot.button(IDialogConstants.YES_LABEL).click();
    }
    bot.button(IDialogConstants.CANCEL_LABEL).click();
  }