Commit ce53ef28 authored by Florine Boudin's avatar Florine Boudin
Browse files

BS-11296 Fix validation on Expression Viewer Constant + add test +

uncomment and complete test on document refactor.
parent 8f8bbcee
......@@ -715,9 +715,11 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
final IObservableValue nameObservable = getExpressionNameObservable();
final IObservableValue typeObservable = getExpressionTypeObservable();
final IObservableValue returnTypeObservable = getExpressionReturnTypeObservable();
final IObservableValue contentObservable = getExpressionContentObservable();
nameObservable.addValueChangeListener(this);
typeObservable.addValueChangeListener(this);
contentObservable.addValueChangeListener(this);
returnTypeObservable.addValueChangeListener(this);
final UpdateValueStrategy targetToModelNameStrategy = new UpdateValueStrategy();
......@@ -775,6 +777,19 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
return returnTypeObservable;
}
protected IObservableValue getExpressionContentObservable() {
IObservableValue returnContentObservable;
final EditingDomain editingDomain = getEditingDomain();
if (editingDomain != null) {
returnContentObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), getSelectedExpressionObservable(),
ExpressionPackage.Literals.EXPRESSION__CONTENT);
} else {
returnContentObservable = EMFObservables.observeDetailValue(Realm.getDefault(), getSelectedExpressionObservable(),
ExpressionPackage.Literals.EXPRESSION__CONTENT);
}
return returnContentObservable;
}
private IObservableValue getSelectedExpressionObservable() {
return ViewersObservables.observeSingleSelection(this);
}
......
......@@ -76,4 +76,8 @@ public class BotProcessDiagramPerspective extends BotBase {
return new BotGefFormDiagramEditor(bot);
}
public void closeActiveDiagram() {
BotProcessDiagramPerspective.this.bot.activeEditor().close();
}
}
......@@ -48,4 +48,22 @@ public class BotAddFormWizardDialog extends BotWizardDialog {
return new BotProcessDataMappingPanel(bot);
}
/**
* Check the selectAll
*/
public BotAddFormWizardDialog selectAll() {
bot.checkBox(Messages.selectAll).select();
return this;
}
/**
* Return content of the Widget column of a given element
*
* @param dataName
* @return
*/
public String getDataWidget(final String dataName) {
return bot.tree().getTreeItem(dataName).cell(1);
}
}
......@@ -8,9 +8,11 @@
*******************************************************************************/
package org.bonitasoft.studio.swtbot.framework.diagram.application.pageflow;
import org.bonitasoft.studio.common.jface.SWTBotConstants;
import org.bonitasoft.studio.properties.i18n.Messages;
import org.bonitasoft.studio.swtbot.framework.BotBase;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
/**
* Pageflow property section.
......@@ -27,4 +29,16 @@ public class BotPageflowPropertySection extends BotBase {
bot.button(Messages.addForm).click();
return new BotAddFormWizardDialog(bot);
}
public void editForm(final String formName) {
selectForm(formName);
bot.button(Messages.editForm).click();
}
private void selectForm(final String formName) {
final SWTBotTree tree = bot.treeWithId(SWTBotConstants.APPLICATION_SECTION_FORMS_SELECTION_TREE);
tree.select(formName);
}
}
......@@ -108,6 +108,19 @@ public class BotAddDocumentDialog extends BotWizardDialog {
bot.textWithLabel(Messages.documentExternalLabel + " *").setText(pURL);
}
/**
* get URL expressionEditor.
*
* @param pURL
*/
public void setURLWithExpressionEditor(final String pURL) {
bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
final BotExpressionEditorDialog editor = new BotExpressionEditorDialog(bot);
editor.selectConstantType().setValue(pURL);
editor.ok();
}
/**
* MULTIPLE CONTENT
*/
......
......@@ -71,4 +71,8 @@ public class BotGefFormDiagramEditor extends BotGefBaseEditor {
gmfEditor.mainEditPart().select();
return this;
}
public void closeGefFormDiagramEditor() {
gmfEditor.close();
}
}
......@@ -24,11 +24,16 @@ import org.bonitasoft.studio.swtbot.framework.application.BotApplicationWorkbenc
import org.bonitasoft.studio.swtbot.framework.composite.BotOperationComposite;
import org.bonitasoft.studio.swtbot.framework.diagram.BotProcessDiagramPerspective;
import org.bonitasoft.studio.swtbot.framework.diagram.BotProcessDiagramPropertiesViewFolder;
import org.bonitasoft.studio.swtbot.framework.diagram.application.pageflow.BotAddFormWizardDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.application.pageflow.BotPageflowPropertySection;
import org.bonitasoft.studio.swtbot.framework.diagram.general.documents.BotAddDocumentDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.general.documents.BotDocumentsPropertySection;
import org.bonitasoft.studio.swtbot.framework.diagram.general.documents.BotEditDocumentDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.general.documents.BotFileStoreSelectDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.general.documents.BotRemoveDocumentDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.general.form.data.BotDataFormPropertySection;
import org.bonitasoft.studio.swtbot.framework.diagram.general.operations.BotOperationsPropertySection;
import org.bonitasoft.studio.swtbot.framework.draw.BotGefFormDiagramEditor;
import org.bonitasoft.studio.swtbot.framework.expression.BotExpressionEditorDialog;
import org.bonitasoft.studio.test.swtbot.util.SWTBotTestUtil;
import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
......@@ -41,7 +46,7 @@ public class TestDocument extends SWTBotGefTestCase {
@Test
public void testAddEditDeleteDocument() {
final BotDocumentsPropertySection botDocumentsPropertySection = createDiagramAndGoToDocumentSection();
BotAddDocumentDialog botAddDocumentDialog = botDocumentsPropertySection.addDocument();
......@@ -53,7 +58,10 @@ public class TestDocument extends SWTBotGefTestCase {
botAddDocumentDialog.setName("doc1Edited");
botAddDocumentDialog.chooseExternalInitialContent();
final boolean isErrorMessageForURLAppeared = botAddDocumentDialog.isErrorMessageUrl();
botAddDocumentDialog.setURL("http://url-test");
botAddDocumentDialog.setURLWithExpressionEditor("http://url-test");
Assertions.assertThat(botAddDocumentDialog.isErrorMessageUrl()).isFalse();
botAddDocumentDialog.ok();
//Delete
......@@ -278,43 +286,66 @@ public class TestDocument extends SWTBotGefTestCase {
}
// @Test
// public void test_UpdateReturnTypeInLeftOperandOperation_when_refactor_document() throws Exception {
// SWTBotTestUtil.pressEnter();
//
// final BotDocumentsPropertySection botDocumentsPropertySection = createDiagramAndGoToDocumentSection();
// final BotAddDocumentDialog botAddDocumentDialog = botDocumentsPropertySection.addDocument();
// botAddDocumentDialog.setName("doc1");
// botAddDocumentDialog.chooseMultipleContent();
// botAddDocumentDialog.finish();
//
// // create form with FileWidget
// final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
// final BotProcessDiagramPerspective botProcessDiagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
//
// botProcessDiagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
// final BotProcessDiagramPropertiesViewFolder botProcessDiagramPropertiesViewFolder = botProcessDiagramPerspective.getDiagramPropertiesPart();
// final BotPageflowPropertySection botOperationsPropertySection = botProcessDiagramPropertiesViewFolder.selectApplicationTab().selectPageflowTab();
// final BotAddFormWizardDialog botAddFormWizardDialog = botOperationsPropertySection.addForm();
// if (botAddFormWizardDialog.canFlipToNextPage()) {
// botAddFormWizardDialog.next();
// }
// final BotProcessDataMappingPanel selectProcessDataTab = botAddFormWizardDialog.selectProcessDataTab();
//
// selectProcessDataTab.selectAll();
// assertEquals("Multiple File", selectProcessDataTab.getDataWidget("doc11"));
// assertEquals("File", selectProcessDataTab.getDataWidget("doc12"));
//
// // check doc11 has a Multiple File widget
// botAddFormWizardDialog.finish();
//
// // Select File widget Doc11
// final BotGefFormDiagramEditor botGef = botProcessDiagramPerspective.activeFormDiagramEditor();
// botGef.selectWidget("Doc11");
//
// // select Data Section in General Tab
// final BotDataFormPropertySectionEx dataSection = botProcessDiagramPerspective.getFormPropertiesPart().selectGeneralTab().selectDataTab();
//
// }
@Test
public void test_UpdateReturnTypeInLeftOperandOperation_when_refactor_document() throws Exception {
final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
final BotProcessDiagramPerspective botProcessDiagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
final BotProcessDiagramPropertiesViewFolder botProcessDiagramPropertiesViewFolder = botProcessDiagramPerspective.getDiagramPropertiesPart();
BotDocumentsPropertySection botDocumentsPropertySection = botProcessDiagramPropertiesViewFolder.selectGeneralTab().selectDocumentsTab();
final BotAddDocumentDialog botAddDocumentDialog = botDocumentsPropertySection.addDocument();
botAddDocumentDialog.setName("doc1");
botAddDocumentDialog.chooseMultipleContent();
botAddDocumentDialog.finish();
// create form with FileWidget
botProcessDiagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
final BotPageflowPropertySection botOperationsPropertySection = botProcessDiagramPropertiesViewFolder.selectApplicationTab().selectPageflowTab();
final BotAddFormWizardDialog botAddFormWizardDialog = botOperationsPropertySection.addForm();
if (botAddFormWizardDialog.canFlipToNextPage()) {
botAddFormWizardDialog.next();
}
botAddFormWizardDialog.selectAll();
assertEquals("File", botAddFormWizardDialog.getDataWidget("doc1"));
// check doc11 has a Multiple File widget
botAddFormWizardDialog.finish();
// Change name of the Document
// Select File widget Doc11
BotGefFormDiagramEditor botGef = botProcessDiagramPerspective.activeFormDiagramEditor();
botGef.selectWidget("Doc1");
// select Data Section in General Tab
BotDataFormPropertySection dataSection = botProcessDiagramPerspective.getFormPropertiesPart().selectGeneralTab().selectDataTab();
Assertions.assertThat(dataSection.getOutputOperation().getLeftOperand()).isEqualTo("doc1");
// close form editor
botGef.closeGefFormDiagramEditor();
// change name of the document
botProcessDiagramPerspective.activeProcessDiagramEditor().selectElement("Pool");
botDocumentsPropertySection = botProcessDiagramPerspective.getDiagramPropertiesPart().selectGeneralTab().selectDocumentsTab();
final BotEditDocumentDialog editDocDialog = botDocumentsPropertySection.editDocument("doc1");
editDocDialog.setName("docEdited");
editDocDialog.ok();
// check name has been changed in the Doc1 Widget in the form Data output
botProcessDiagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
final BotPageflowPropertySection pageFlowPropertySection = botProcessDiagramPerspective.getDiagramPropertiesPart().selectApplicationTab()
.selectPageflowTab();
pageFlowPropertySection.editForm("Step1");
botGef = botProcessDiagramPerspective.activeFormDiagramEditor();
botGef.selectWidget("Doc1");
dataSection = botProcessDiagramPerspective.getFormPropertiesPart().selectGeneralTab().selectDataTab();
Assertions.assertThat(dataSection.getOutputOperation().getLeftOperand()).isEqualTo("docEdited");
}
}
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