Commit 4a36e67d authored by Adrien's avatar Adrien Committed by Romain Bioteau
Browse files

feat(project explorer) test actor filter actions from explorer (#1433)

parent 9740d9a9
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.projectExplorer;
import org.bonitasoft.studio.swtbot.framework.BotDialog;
import org.bonitasoft.studio.swtbot.framework.connector.ConnectorDefinitionWizardBot;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class ActorFilterDefinitionProjectExplorerBot extends ProjectExplorerBot {
public ActorFilterDefinitionProjectExplorerBot(SWTGefBot bot) {
super(bot);
}
@Override
public ConnectorDefinitionWizardBot newConnectorDefinition() {
clickOnContextualMenu(getActorFilterDefFolderTreeItem(), "New...");
return new ConnectorDefinitionWizardBot(bot,
org.bonitasoft.studio.actors.i18n.Messages.newFilterDefinition);
}
public ConnectorDefinitionWizardBot openActorFilterDefinition(String actorFilterDef, String version) {
clickOnContextualMenu(getActorFilterDefTreeItem(actorFilterDef, version), "Open");
return new ConnectorDefinitionWizardBot(bot, org.bonitasoft.studio.actors.i18n.Messages.editFilterDefinition);
}
public ConnectorDefinitionWizardBot renameActorFilterDefinition(String actorFilterDef, String version) {
clickOnContextualMenu(getActorFilterDefTreeItem(actorFilterDef, version), "Rename...");
return new ConnectorDefinitionWizardBot(bot, org.bonitasoft.studio.actors.i18n.Messages.editFilterDefinition);
}
public BotDialog exportActorFilterFromDefinition(String actorFilterDef, String version) {
clickOnContextualMenu(getActorFilterDefTreeItem(actorFilterDef, version), "Export...");
return new BotDialog(bot, org.bonitasoft.studio.actors.i18n.Messages.selectFilterImplementationToExportTitle);
}
public void deleteActorFilterDefinition(String connectorDef, String version) {
clickOnContextualMenu(getActorFilterDefTreeItem(connectorDef, version), "Delete");
}
public SWTBotTreeItem getActorFilterDefTreeItem(String actorFilterDef, String version) {
return getTreeItem(getActorFilterDefFolderTreeItem(), toFileName(actorFilterDef, version));
}
public SWTBotTreeItem getActorFilterDefFolderTreeItem() {
return getTreeItem(getProjectTreeItem(), "Actor filter definitions");
}
public String toFileName(String connectorDef, String version) {
return String.format("%s-%s.def", connectorDef, version);
}
}
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.projectExplorer;
import org.bonitasoft.studio.swtbot.framework.BotDialog;
import org.bonitasoft.studio.swtbot.framework.connector.ConnectorImplementationWizardBot;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class ActorFilterImplementationProjectExplorerBot extends ProjectExplorerBot {
public ActorFilterImplementationProjectExplorerBot(SWTGefBot bot) {
super(bot);
}
@Override
public ConnectorImplementationWizardBot newActorFilterImplementation() {
clickOnContextualMenu(getActorFilterImplFolderTreeItem(), "New...");
return new ConnectorImplementationWizardBot(bot,
org.bonitasoft.studio.actors.i18n.Messages.newFilterImplementation);
}
public ConnectorImplementationWizardBot openActorFilterImplementation(String connectorImpl, String version) {
clickOnContextualMenu(getActorFilterImplTreeItem(connectorImpl, version), "Open");
return new ConnectorImplementationWizardBot(bot,
org.bonitasoft.studio.actors.i18n.Messages.editFilterImplementation);
}
public BotDialog exportActorFilterImplementation(String connectorImpl, String version) {
clickOnContextualMenu(getActorFilterImplTreeItem(connectorImpl, version), "Export...");
return new BotDialog(bot, org.bonitasoft.studio.actors.i18n.Messages.selectFilterImplementationToExportTitle);
}
public BotDialog exportActorFilterImplementation() {
clickOnContextualMenu(getActorFilterImplFolderTreeItem(), "Export...");
return new BotDialog(bot, org.bonitasoft.studio.actors.i18n.Messages.selectFilterImplementationToExportTitle);
}
public void deleteActorFilterImplementation(String connectorImpl, String version) {
clickOnContextualMenu(getActorFilterImplTreeItem(connectorImpl, version), "Delete");
}
public SWTBotTreeItem getActorFilterImplTreeItem(String connectorDef, String version) {
return getTreeItem(getActorFilterImplFolderTreeItem(), toFileName(connectorDef, version));
}
public SWTBotTreeItem getActorFilterImplFolderTreeItem() {
return getTreeItem(getProjectTreeItem(), "Actor filter implementations");
}
public String toFileName(String connectorImpl, String version) {
return String.format("%s-%s.impl", connectorImpl, version);
}
}
/*******************************************************************************
* Copyright (C) 2018 BonitaSoft S.A.
* BonitaSoft is a trademark of BonitaSoft SA.
* This software file is BONITASOFT CONFIDENTIAL. Not For Distribution.
* For commercial licensing information, contact:
* BonitaSoft, 32 rue Gustave Eiffel – 38000 Grenoble
* or BonitaSoft US, 51 Federal Street, Suite 305, San Francisco, CA 94107
*******************************************************************************/
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.swtbot.framework.projectExplorer;
import org.bonitasoft.studio.swtbot.framework.BotDialog;
......
......@@ -96,6 +96,20 @@ public class ProjectExplorerBot extends BotBase {
org.bonitasoft.studio.connectors.i18n.Messages.newConnectorImplementation);
}
public ConnectorDefinitionWizardBot newActorFilterDefinition() {
SWTBotTreeItem projectTreeItem = getProjectTreeItem();
bot.waitUntil(contextMenuAvailable(projectTreeItem, "New"));
projectTreeItem.contextMenu().menu("New").menu("Actor filter definition...").click();
return new ConnectorDefinitionWizardBot(bot, org.bonitasoft.studio.actors.i18n.Messages.newFilterDefinition);
}
public ConnectorImplementationWizardBot newActorFilterImplementation() {
SWTBotTreeItem projectTreeItem = getProjectTreeItem();
bot.waitUntil(contextMenuAvailable(projectTreeItem, "New"));
projectTreeItem.contextMenu().menu("New").menu("Actor filter implementation...").click();
return new ConnectorImplementationWizardBot(bot, org.bonitasoft.studio.actors.i18n.Messages.newFilterImplementation);
}
public OrganizationProjectExplorerBot organization() {
return new OrganizationProjectExplorerBot(bot);
}
......@@ -120,6 +134,14 @@ public class ProjectExplorerBot extends BotBase {
return new ConnectorImplementationProjectExplorerBot(bot);
}
public ActorFilterDefinitionProjectExplorerBot actorFilterDefinition() {
return new ActorFilterDefinitionProjectExplorerBot(bot);
}
public ActorFilterImplementationProjectExplorerBot actorFilterImplementation() {
return new ActorFilterImplementationProjectExplorerBot(bot);
}
public SWTBotTreeItem getProjectTreeItem() {
return getProjectExplorerTree().getTreeItem(projectName);
}
......
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.tests.projectExplorer;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Optional;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.swtbot.framework.BotDialog;
import org.bonitasoft.studio.swtbot.framework.projectExplorer.ActorFilterDefinitionProjectExplorerBot;
import org.bonitasoft.studio.swtbot.framework.projectExplorer.ActorFilterImplementationProjectExplorerBot;
import org.bonitasoft.studio.swtbot.framework.projectExplorer.ProjectExplorerBot;
import org.bonitasoft.studio.swtbot.framework.rule.SWTGefBotRule;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class ProjectExplorerActorFilterIT {
private static final String VERSION = "1.0.0";
private SWTGefBot bot = new SWTGefBot();
private ProjectExplorerBot projectExplorerBot;
private RepositoryAccessor repositoryAccessor;
@Rule
public SWTGefBotRule botRule = new SWTGefBotRule(bot);
@Before
public void init() throws Exception {
projectExplorerBot = new ProjectExplorerBot(bot);
repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
}
@Test
public void should_manage_connectors_from_explorer() {
ActorFilterDefinitionProjectExplorerBot actorFilterDefBot = projectExplorerBot.actorFilterDefinition();
ActorFilterImplementationProjectExplorerBot actorFilterImplBot = projectExplorerBot.actorFilterImplementation();
String defid1 = "projectExplorerActorDef";
String defid2 = "projectExplorerActorDef2";
String implemId1 = "projectExplorerActorImplementationId";
String implemId2 = "projectExplorerActorImplementationId2";
String className1 = "actorImplemClassName1";
String className2 = "actoIimplemClassName2";
projectExplorerBot.newActorFilterDefinition()
.withDefinitionId(defid1)
.withDefinitionVersion(VERSION)
.finish();
actorFilterDefBot.getActorFilterDefFolderTreeItem().expand();
actorFilterDefBot.getActorFilterDefFolderTreeItem().collapse();
actorFilterDefBot.openActorFilterDefinition(defid1, VERSION).cancel();
actorFilterDefBot.renameActorFilterDefinition(defid1, VERSION).withDefinitionId(defid2).finish();
actorFilterDefBot.newConnectorDefinition()
.withDefinitionId(defid1)
.withDefinitionVersion(VERSION)
.finish();
projectExplorerBot.newActorFilterImplementation()
.selectDefinition(defid1)
.nextPage()
.withImplementationId(implemId1)
.withImplementationVersion(VERSION)
.withClassName(className1)
.finish();
projectExplorerBot.waitUntilActiveEditorTitleIs(className1, Optional.of(".java"));
actorFilterImplBot.openActorFilterImplementation(implemId1, VERSION).cancel();
actorFilterImplBot.newActorFilterImplementation()
.selectDefinition(defid1)
.nextPage()
.withImplementationId(implemId2)
.withImplementationVersion(VERSION)
.withClassName(className2)
.finish();
projectExplorerBot.waitUntilActiveEditorTitleIs(className2, Optional.of(".java"));
BotDialog botDialog = actorFilterImplBot.exportActorFilterImplementation();
assertThat(bot.table().containsItem(toFullImplementationName(implemId1, className1))).isTrue();
botDialog.cancel();
botDialog = actorFilterImplBot.exportActorFilterImplementation(implemId1, VERSION);
assertThat(bot.table().rowCount()).isEqualTo(1);
assertThat(bot.table().containsItem(toFullImplementationName(implemId1, className1))).isTrue();
botDialog.cancel();
botDialog = actorFilterDefBot.exportActorFilterFromDefinition(defid1, VERSION);
assertThat(bot.table().rowCount()).isEqualTo(2);
assertThat(bot.table().containsItem(toFullImplementationName(implemId1, className1))).isTrue();
assertThat(bot.table().containsItem(toFullImplementationName(implemId2, className2))).isTrue();
botDialog.cancel();
actorFilterImplBot.deleteActorFilterImplementation(implemId2, VERSION);
actorFilterImplBot.deleteActorFilterImplementation(implemId1, VERSION);
actorFilterDefBot.deleteActorFilterDefinition(defid2, VERSION);
actorFilterDefBot.deleteActorFilterDefinition(defid1, VERSION);
}
private String toFullImplementationName(String implemId, String className) {
return String.format("%s (%s) -- org.mycompany.connector.%s", implemId, VERSION, className);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment