Commit 0b6ac758 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

feat(deploy) add swtbot test (#1863)

Closes BST-475
parent e46087af
......@@ -12,7 +12,8 @@ Export-Package: org.bonitasoft.studio.actors,
x-friends:="org.bonitasoft.studio.actors.tests,
org.bonitasoft.studio.test.swtbot.util,
org.bonitasoft.studio.tests,
org.bonitasoft.studio.application",
org.bonitasoft.studio.application,
org.bonitasoft.studio.swtbot.framework",
org.bonitasoft.studio.actors.model.organization,
org.bonitasoft.studio.actors.model.organization.impl,
org.bonitasoft.studio.actors.model.organization.util,
......
......@@ -274,7 +274,7 @@ public class DeployArtifactsHandler {
if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.WARNING) {
MultiStatusDialog multiStatusDialog = new MultiStatusDialog(activeShell, Messages.deployStatus,
Messages.deployStatusMessage,
new String[] { IDialogConstants.OK_LABEL }, (MultiStatus) status);
new String[] { IDialogConstants.CLOSE_LABEL }, (MultiStatus) status);
multiStatusDialog.setLevel(IStatus.WARNING);
multiStatusDialog.open();
} else {
......
......@@ -89,13 +89,13 @@ public class RepositoryModelBuilder {
public void createProcessArtifacts(RepositoryStore parent, DiagramFileStore fStore) {
final List<Artifact> processes = parent.getArtifacts();
for (AbstractProcess procModel : fStore.getProcesses()) {
ProcessArtifact defaultProcess = new ProcessArtifact(parent, procModel.getName(), fStore);
ProcessArtifact defaultProcess = new ProcessArtifact(parent, procModel.getName());
ProcessArtifact process = (ProcessArtifact) processes.stream().filter(defaultProcess::equals).findFirst()
.orElse(defaultProcess);
if (!processes.contains(process)) {
processes.add(process);
}
process.addVersion((Pool) procModel);
process.addVersion((Pool) procModel, fStore);
}
}
}
......@@ -125,8 +125,8 @@ public class SelectArtifactToDeployPage implements ControlSupplier {
cleanBDM = section.getBoolean(CLEAN_BDM_DEFAULT_SELECTION);
validate = section.getBoolean(VALIDATE_DEFAULT_SELECTION);
}
environment = ConfigurationPlugin.getDefault().getPreferenceStore()
.getString(ConfigurationPreferenceConstants.DEFAULT_CONFIGURATION);
String activeEnvironment = ConfigurationPlugin.getDefault().getPreferenceStore().getString(ConfigurationPreferenceConstants.DEFAULT_CONFIGURATION);
environment = environmentProvider.getEnvironment().contains(activeEnvironment) ? activeEnvironment : ConfigurationPreferenceConstants.LOCAL_CONFIGURAITON;
}
......
......@@ -29,22 +29,20 @@ import org.eclipse.swt.graphics.Image;
public class ProcessArtifact implements VersionedArtifact {
private List<ArtifactVersion> processVerions = new ArrayList<>();
private DiagramFileStore fStore;
private String name;
private RepositoryStore parent;
public ProcessArtifact(RepositoryStore parent,String name, DiagramFileStore fStore) {
public ProcessArtifact(RepositoryStore parent, String name) {
this.parent = parent;
this.name = name;
this.fStore = fStore;
}
public String getName() {
return name;
}
public void addVersion(Pool process) {
processVerions.add(new ProcessVersion(this, process));
public void addVersion(Pool process, DiagramFileStore fStore) {
processVerions.add(new ProcessVersion(this, process, fStore));
Collections.sort(processVerions);
}
......@@ -97,10 +95,6 @@ public class ProcessArtifact implements VersionedArtifact {
return processVerions.get(0);
}
public DiagramFileStore getFileStore() {
return fStore;
}
@Override
public boolean hasSingleVersion() {
return processVerions.size() == 1;
......
......@@ -44,8 +44,8 @@ public class ProcessVersion extends BuildableArtifact implements ArtifactVersion
private ProcessArtifact process;
private Pool model;
public ProcessVersion(ProcessArtifact process, Pool model) {
super(process, process.getFileStore());
public ProcessVersion(ProcessArtifact process, Pool model, DiagramFileStore fStore) {
super(process, fStore);
this.process = process;
this.model = model;
this.version = new DefaultArtifactVersion(model.getVersion());
......@@ -70,11 +70,11 @@ public class ProcessVersion extends BuildableArtifact implements ArtifactVersion
processFolder.create(true, true, new NullProgressMonitor());
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("fileName", getParent().getFileStore().getName());
parameters.put("fileName", getFileStore().getName());
parameters.put("destinationPath", processFolder.getLocation().toOSString());
parameters.put("process", ModelHelper.getEObjectID(getModel()));
monitor.subTask(String.format(Messages.buildingProcess, getName()));
IStatus buildStatus = (IStatus) getParent().getFileStore().executeCommand(DiagramFileStore.BUILD_DIAGRAM_COMMAND, parameters);
IStatus buildStatus = (IStatus) ((DiagramFileStore)getFileStore()).executeCommand(DiagramFileStore.BUILD_DIAGRAM_COMMAND, parameters);
if (Objects.equals(buildStatus.getSeverity(), ValidationStatus.ERROR)) {
throw new CoreException(parseStatus(buildStatus));
}
......
......@@ -13,7 +13,7 @@ Export-Package: org.bonitasoft.studio.businessobject,
org.bonitasoft.studio.businessobject.core.difflog,
org.bonitasoft.studio.businessobject.core.operation,
org.bonitasoft.studio.businessobject.core.repository,
org.bonitasoft.studio.businessobject.i18n;x-friends:="org.bonitasoft.studio.tests",
org.bonitasoft.studio.businessobject.i18n;x-friends:="org.bonitasoft.studio.tests,org.bonitasoft.studio.swtbot.framework",
org.bonitasoft.studio.businessobject.ui,
org.bonitasoft.studio.businessobject.ui.expression,
org.bonitasoft.studio.businessobject.ui.handler,
......
......@@ -170,7 +170,6 @@ public class DeployBDMOperation implements IRunnableWithProgress {
}
throw new InvocationTargetException(e);
} finally {
if (tenantManagementAPI != null && tenantManagementAPI.isPaused()) {
try {
tenantManagementAPI.resume();
......
......@@ -49,7 +49,7 @@ Export-Package: org.bonitasoft.studio.connectors,
org.bonitasoft.studio.connectors.expression,
org.bonitasoft.studio.connectors.extension,
org.bonitasoft.studio.connectors.handler,
org.bonitasoft.studio.connectors.i18n;x-friends:="org.bonitasoft.studio.tests.ex,org.bonitasoft.studio.connectors.test",
org.bonitasoft.studio.connectors.i18n;x-friends:="org.bonitasoft.studio.tests.ex,org.bonitasoft.studio.connectors.test,org.bonitasoft.studio.swtbot.framework",
org.bonitasoft.studio.connectors.operation,
org.bonitasoft.studio.connectors.repository,
org.bonitasoft.studio.connectors.ui.property.section,
......
......@@ -44,6 +44,16 @@ public class WebWidgetFileStore extends InFolderJSONFileStore implements WebReso
}
return super.canBeExported();
}
@Override
public boolean canBeDeleted() {
try {
return getBooleanAttribute("custom");
} catch (JSONException | ReadFileStoreException e) {
BonitaStudioLog.error(String.format("Failed to retrieve 'custom' attribute in widget %s", getName()), e);
}
return super.canBeDeleted();
}
@Override
public Image getIcon() {
......
......@@ -21,8 +21,8 @@ import org.bonitasoft.studio.importer.bos.wizard.ImportBosArchiveControlSupplier
import org.bonitasoft.studio.importer.ui.dialog.SkippableProgressMonitorJobsDialog;
import org.bonitasoft.studio.ui.dialog.ExceptionDialogHandler;
import org.bonitasoft.studio.ui.wizard.WizardBuilder;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
......@@ -73,9 +73,8 @@ public class ImportBosHandler {
} catch (final InvocationTargetException | InterruptedException e) {
throw new RuntimeException(e);
}
operation.openFilesToOpen();
PlatformUtil.openIntroIfNoOtherEditorOpen();
activeShell.getDisplay().asyncExec(() -> openEndImportDialog(operation.getStatus(),
activeShell.getDisplay().asyncExec(() -> openEndImportDialog(operation,
repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class), activeShell,
repositoryAccessor.getCurrentRepository().getName()));
}
......@@ -85,9 +84,12 @@ public class ImportBosHandler {
return new ImportBosArchiveOperation(archive, progressManager, model, repositoryAccessor);
}
protected void openEndImportDialog(IStatus status, DiagramRepositoryStore store, Shell activeShell,
protected void openEndImportDialog(ImportBosArchiveOperation operation, DiagramRepositoryStore store, Shell activeShell,
String repositoryName) {
new BosImportStatusDialogHandler(status, store).open(activeShell);
if(new BosImportStatusDialogHandler(operation.getStatus(), store).open(activeShell) != IDialogConstants.PROCEED_ID) {
operation.openFilesToOpen();
PlatformUtil.openIntroIfNoOtherEditorOpen();
}
}
protected Repository getTargetRepository(RepositoryAccessor repositoryAccessor) {
......
......@@ -47,7 +47,7 @@ public class BosImportStatusDialogHandler extends DefaultImportStatusDialogHandl
}
@Override
protected void openImportStatus(final Shell parentShell, String message) {
protected int openImportStatus(final Shell parentShell, String message) {
final ImportStatusDialog messageDialog = new ImportStatusDialog(parentShell, importStatus, message,
importStatus instanceof BosArchiveImportStatus
&& !((BosArchiveImportStatus) importStatus).getProcessesWithErrors().isEmpty());
......@@ -59,6 +59,7 @@ public class BosImportStatusDialogHandler extends DefaultImportStatusDialogHandl
executeCommand("org.bonitasoft.studio.application.command.deployArtifacts");
}
}
return result;
}
private void executeCommand(String command) {
......
......@@ -17,6 +17,7 @@ package org.bonitasoft.studio.importer.handler;
import java.util.Optional;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
......@@ -41,30 +42,28 @@ public class DefaultImportStatusDialogHandler implements ImportStatusDialogHandl
}
@Override
public void open(final Shell parentShell) {
public int open(final Shell parentShell) {
if (importStatus.getSeverity() == IStatus.WARNING
&& (importStatus.getChildren() == null || importStatus.getChildren().length == 0)) {
MessageDialog.openWarning(parentShell, org.bonitasoft.studio.importer.i18n.Messages.importResultTitle,
importStatus.getMessage());
return IDialogConstants.CLOSE_ID;
} else {
switch (importStatus.getSeverity()) {
case IStatus.OK:
openImportStatus(parentShell, customSuccessMessage.orElse(org.bonitasoft.studio.importer.i18n.Messages.importSucessfulMessage));
break;
return openImportStatus(parentShell, customSuccessMessage.orElse(org.bonitasoft.studio.importer.i18n.Messages.importSucessfulMessage));
case IStatus.INFO:
openImportStatus(parentShell, customSuccessMessage
return openImportStatus(parentShell, customSuccessMessage
.orElse(org.bonitasoft.studio.importer.i18n.Messages.importSucessfulMessage));
break;
default:
openImportStatus(parentShell,
return openImportStatus(parentShell,
customErrorMessage.orElse(org.bonitasoft.studio.importer.i18n.Messages.importStatusMsg));
break;
}
}
}
protected void openImportStatus(Shell parentShell, String message) {
new ImportStatusDialog(parentShell, importStatus, message, false).open();
protected int openImportStatus(Shell parentShell, String message) {
return new ImportStatusDialog(parentShell, importStatus, message, false).open();
}
}
......@@ -16,11 +16,8 @@ package org.bonitasoft.studio.importer.handler;
import org.eclipse.swt.widgets.Shell;
/**
* @author Romain Bioteau
*/
public interface ImportStatusDialogHandler {
void open(final Shell parentShell);
int open(final Shell parentShell);
}
......@@ -199,4 +199,9 @@ public class BotApplicationWorkbenchWindow extends AbstractBotMenu {
bot.shell(org.bonitasoft.studio.businessobject.i18n.Messages.manageBusinessDataModelTitle).activate().setFocus();
return new DefineBdmWizardBot(bot, org.bonitasoft.studio.businessobject.i18n.Messages.manageBusinessDataModelTitle);
}
public BotDeployDialog openDeploy() {
bot.menu("File").menu("Deploy...").click();
return new BotDeployDialog(bot);
}
}
/**
* Copyright (C) 2014 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.application;
import org.bonitasoft.studio.application.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotDialog;
import org.bonitasoft.studio.swtbot.framework.widget.BotTreeWidget;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
public class BotDeployDialog extends BotDialog {
public BotDeployDialog(final SWTGefBot bot) {
super(bot, Messages.selectArtifactToDeployTitle);
}
public BotDeployDialog searchArtifacts(final String searchText) {
bot.text(0).setText(searchText);
return this;
}
public BotDeployDialog setDefaultUser(String username) {
bot.textWithLabelInGroup(org.bonitasoft.studio.actors.i18n.Messages.defaultUser, Messages.deployOptions)
.setText(username);
return this;
}
public boolean isDefaultUserEnabled() {
return bot.textWithLabelInGroup(org.bonitasoft.studio.actors.i18n.Messages.defaultUser, Messages.deployOptions)
.isEnabled();
}
public BotDeployDialog cleanBDMDatabase(boolean clean) {
if (clean) {
bot.checkBoxInGroup(Messages.cleanBDMDatabase, Messages.deployOptions).select();
} else {
bot.checkBoxInGroup(Messages.cleanBDMDatabase, Messages.deployOptions).deselect();
}
return this;
}
public boolean isCleanBDMDatabaseEnabled() {
return bot.checkBoxInGroup(Messages.cleanBDMDatabase, Messages.deployOptions).isEnabled();
}
public boolean isCleanBDMDatabaseSelected() {
return bot.checkBoxInGroup(Messages.cleanBDMDatabase, Messages.deployOptions).isChecked();
}
public BotDeployDialog runValidation(boolean validate) {
if (validate) {
bot.checkBoxInGroup(Messages.validateProcess, Messages.deployOptions).select();
} else {
bot.checkBoxInGroup(Messages.validateProcess, Messages.deployOptions).deselect();
}
return this;
}
public boolean isValidateSelected() {
return bot.checkBoxInGroup(Messages.validateProcess, Messages.deployOptions).isChecked();
}
public BotDialog deploy() {
bot.button(Messages.deploy).click();
bot.waitUntil(Conditions.shellIsActive(Messages.deployStatus), 120000);
return new BotDialog(bot, Messages.deployStatus);
}
public boolean isDeployEnabled() {
return bot.button(Messages.deploy).isEnabled();
}
public BotTreeWidget artifactsTree() {
return new BotTreeWidget(bot.tree());
}
public BotDeployDialog selectNone() {
bot.button(Messages.selectNone).click();
return this;
}
public BotDeployDialog selectAll() {
bot.button(Messages.selectAll).click();
return this;
}
public BotDeployDialog selectLatest() {
bot.button(Messages.selectLatestVersion).click();
return this;
}
}
......@@ -33,7 +33,6 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
@SuppressWarnings("restriction")
public class DefineBdmWizardBot extends BotWizardDialog {
public DefineBdmWizardBot(SWTGefBot bot, String dialogTitle) {
......
......@@ -17,7 +17,6 @@ package org.bonitasoft.studio.swtbot.framework.connector;
import org.bonitasoft.studio.swtbot.framework.BotWizardDialog;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
@SuppressWarnings("restriction")
public class ConnectorDefinitionWizardBot extends BotWizardDialog {
public ConnectorDefinitionWizardBot(SWTGefBot bot, String dialogTitle) {
......
......@@ -21,6 +21,7 @@ import java.net.URL;
import org.bonitasoft.studio.importer.bos.i18n.Messages;
// import org.bonitasoft.studio.importer.bos.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotWizardDialog;
import org.bonitasoft.studio.swtbot.framework.application.BotDeployDialog;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Display;
......@@ -74,6 +75,18 @@ public class BotImportBOSDialog extends BotWizardDialog {
bot.button(IDialogConstants.OK_LABEL).click();
bot.waitUntil(Conditions.shellCloses(activeShell));
}
public BotDeployDialog importAndDeploy() {
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(Messages.importButtonLabel)), 10000);
bot.button(Messages.importButtonLabel).click();
bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.importer.i18n.Messages.importResultTitle), 120000);
bot.shell(org.bonitasoft.studio.importer.i18n.Messages.importResultTitle).activate();
final SWTBotShell activeShell = bot.activeShell();
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)));
bot.button(org.bonitasoft.studio.importer.i18n.Messages.deploy).click();
bot.waitUntil(Conditions.shellCloses(activeShell));
return new BotDeployDialog(bot);
}
private String toAbsoluteFilePath(URL bosURLInClasspath) throws IOException {
return new File(FileLocator.toFileURL(bosURLInClasspath).getFile()).getAbsolutePath();
......
......@@ -19,7 +19,6 @@ import org.bonitasoft.studio.swtbot.framework.connector.ConnectorDefinitionWizar
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) {
......
......@@ -19,7 +19,6 @@ import org.bonitasoft.studio.swtbot.framework.connector.ConnectorImplementationW
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) {
......
......@@ -19,7 +19,6 @@ import org.bonitasoft.studio.swtbot.framework.connector.ConnectorDefinitionWizar
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class ConnectorDefinitionProjectExplorerBot extends ProjectExplorerBot {
public ConnectorDefinitionProjectExplorerBot(SWTGefBot bot) {
......
......@@ -19,7 +19,6 @@ import org.bonitasoft.studio.swtbot.framework.connector.ConnectorImplementationW
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class ConnectorImplementationProjectExplorerBot extends ProjectExplorerBot {
public ConnectorImplementationProjectExplorerBot(SWTGefBot bot) {
......
......@@ -26,7 +26,6 @@ import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class OrganizationProjectExplorerBot extends ProjectExplorerBot {
private static final String ORGA_EXT = ".organization";
......
......@@ -38,7 +38,6 @@ import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@SuppressWarnings("restriction")
public class ProjectExplorerBot extends BotBase {
protected String projectName;
......
......@@ -14,8 +14,6 @@
*/
package org.bonitasoft.studio.swtbot.framework.rule;
import static org.bonitasoft.studio.swtbot.framework.conditions.BonitaBPMConditions.activeWelcomePage;
import org.bonitasoft.studio.application.actions.coolbar.NormalCoolBarHandler;
import org.bonitasoft.studio.common.jface.FileActionDialog;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
......
......@@ -42,6 +42,7 @@ import org.bonitasoft.studio.tests.connectors.TestLoadSaveConnectorConfiguration
import org.bonitasoft.studio.tests.connectors.TestTextAreaInConnectorWizard;
import org.bonitasoft.studio.tests.contract.ContractIT;
import org.bonitasoft.studio.tests.data.DataWizardIT;
import org.bonitasoft.studio.tests.deploy.DeployWizardIT;
import org.bonitasoft.studio.tests.diagram.ConvertActivityTypeWithBoundariesIT;
import org.bonitasoft.studio.tests.diagram.CopyPasteTests;
import org.bonitasoft.studio.tests.diagram.DeleteCommandTest;
......@@ -155,6 +156,7 @@ import org.junit.runners.Suite;
BPMNConnectorExportImportTest.class,
BPMNGatewayExportImportTest.class,
BPMNEventSubProcessExportImportTest.class,
DeployWizardIT.class,
OrganizationCreationTest.class
})
public class SWTBotTestSuite {
......
......@@ -27,6 +27,7 @@ Import-Package: javax.xml.bind;version="2.2.0",
org.bonitasoft.engine.expression,
org.bonitasoft.engine.form,
org.bonitasoft.engine.identity,
org.bonitasoft.engine.page,
org.bonitasoft.engine.platform,
org.bonitasoft.engine.search,
org.bonitasoft.engine.session,
......
/**
* Copyright (C) 2019 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,