Commit 1d1bd6e5 authored by Bonita CI's avatar Bonita CI
Browse files

Merge branch 'master' into 'R2D2-7.2'

parents 5b4452cc 68ef9f66
......@@ -98,8 +98,8 @@ dropBusinessDataDBOnExit=Clean business data database on exit
dropBusinessDataDBOnBDMChanges=Clean business data database on changes
queryExpressionGuidance=Select the Business Object and the corresponding query to execute. Set the value for each parameter required by the query.
bdmCompatibilityTitle=Warning: Impact of changes
bdmCompatibilityMsg=This BDM is available to all processes in your Studio, and to pages using REST API calls. Changing the BDM might cause inconsistencies.\nAfter the BDM update, validate each diagram and check your pages.\nIf you have changed the Mandatory or Multiple setting for an attribute, a unique constraint, or if you have changed a Business Object attribute Type you must clear the values of the business data in the database.
clearExistingBusinessData=Clear data
bdmCompatibilityMsg=This BDM is available to all processes in your Studio, and to application pages and process forms using REST API calls. Changing the BDM might cause inconsistencies.\nAfter the BDM update, validate each diagram and check your pages and forms.\n\nIf you have changed the Mandatory or Multiple setting for an attribute, a unique constraint, or if you have changed a non-primitive attribute type, you must reset the BDM database structure and data.
clearExistingBusinessData=Reset BDM database
businessObjectNameAlreadyExists=A Business Object already exists with the same name
installFailedTitle=Deploy failed
installFailedMessage=An error occurred while deploying the Business Data Model in engine
......
......@@ -135,6 +135,27 @@ public class RepositoryManager {
if (project == null || !project.exists()) {
return null;
}
boolean toClose = false;
try {
if (!project.isAccessible()) {
project.open(Repository.NULL_PROGRESS_MONITOR);
toClose = true;
}
if (!project.hasNature(BonitaProjectNature.NATURE_ID)) {
return null;
}
} catch (final CoreException e) {
BonitaStudioLog.error(e);
return null;
} finally {
if (toClose) {
try {
project.close(Repository.NULL_PROGRESS_MONITOR);
} catch (final CoreException e) {
BonitaStudioLog.error(e);
}
}
}
return createRepository(repositoryName, migrationEnabled);
}
......
/**
* Copyright (C) 2012-2014 Bonitasoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* Copyright (C) 2012-2015 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
......@@ -180,6 +180,7 @@ public class ExportRepositoryWizardPage extends WizardPage {
@Override
public void widgetSelected(final SelectionEvent e) {
checkedElementsObservable.clear();
final ITreeContentProvider provider = (ITreeContentProvider) treeViewer.getContentProvider();
checkedElementsObservable.addAll(Arrays.asList(provider.getElements(stores)));
}
......
......@@ -19,7 +19,9 @@ import static com.google.common.collect.Iterables.find;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import org.bonitasoft.engine.bpm.document.DocumentValue;
import org.bonitasoft.studio.common.DataUtil;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.Messages;
......@@ -401,7 +403,7 @@ public class ExpressionHelper {
public static Operation createDefaultConnectorOutputOperation(final Output output) {
final Operation operation = ExpressionFactory.eINSTANCE.createOperation();
final Operator assignment = ExpressionFactory.eINSTANCE.createOperator();
assignment.setType(ExpressionConstants.ASSIGNMENT_OPERATOR);
assignment.setType(isDocumentValue(output) ? ExpressionConstants.SET_DOCUMENT_OPERATOR : ExpressionConstants.ASSIGNMENT_OPERATOR);
operation.setOperator(assignment);
final Expression rightOperand = ExpressionFactory.eINSTANCE.createExpression();
......@@ -417,6 +419,10 @@ public class ExpressionHelper {
return operation;
}
private static boolean isDocumentValue(Output output) {
return Objects.equals(DocumentValue.class.getName(), output.getType());
}
public static Data dataFromIteratorExpression(final MultiInstantiable parentFlowElement, final Expression iteratorExpression, final MainProcess mainProcess) {
final String returnType = iteratorExpression.getReturnType();
Data d = null;
......
......@@ -12,7 +12,7 @@
* 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.designer.ui.property.section.control;
package org.bonitasoft.studio.common.widgets;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Composite;
......
......@@ -125,7 +125,7 @@ alwaysUseScriptingModeOutputPref=Always use the scripting mode output (hide outp
unsuportedExpressionTypeForTesting=Unsupported expression type for testing:
unresolvedPatternOrScriptExpression=Input parameter {0} use an expression containing unreachable reference
unresolvedExpression=Input parameter {0} uses an unreachable Expression
deleteConnectorDefinition=Do you want to delete the connector definition {0} and the associated implementation(s) and saved configuration(s)?
deleteConnectorDefinition=Do you want to delete the connector definition {0} and the associated implementation(s) and saved configuration(s)?\nThe connector implementation will be removed but the Java source files will not be deleted because they might be used by other connectors.
configurationChangedTitle=Configuration inconsistency
configurationChangedMsg=Changes to this configuration have been made to match the new definition of this connector.\nPlease check that everything is consistent.
connectorOutput=Output parameter
......
......@@ -23,7 +23,8 @@ processInstantiationInputs=Process instantiation inputs
inputTabLabel=Inputs
constraintsTabLabel=Constraints
contractInputTypeLabel=Contract Input
removeInputConfirmationMessage=Are you sure you want to remove the following input?\nIf this input is COMPLEX it will remove all children.\nIf this input is a single reference of a constraint, this constraint will be removed.
removeInputConfirmationMessagePart1=Are you sure you want to remove the following input?
removeInputConfirmationMessagesPart2=\nIf this input is COMPLEX it will remove all children.\nIf this input is a single reference of a constraint, this constraint will be removed.
removeInputConfirmationTitle=Are you sure you want to remove contract input?
removeConstraintConfirmationTitle=Are you sure you want to remove contract constraint(s)?
removeConstraintConfirmationMessage=Are you sure you want to remove following constraint(s)?
......@@ -44,8 +45,8 @@ nullable=Nullable
removeInputErrorTitle=Remove failed
removeInputErrorMsg=An error occurred when removing contract input.
severalCompilationErrors={0} compilation errors found.
SelectBusinessDataWizardPageTitle=Select business data
selectBusinessDataWizardPageDescription=Select business variable from which contract input will be generated.
SelectBusinessDataWizardPageTitle=Select business data or document
selectBusinessDataWizardPageDescription=Select business variable or document from which contract input will be generated.
generate=Add from data...
contractInputGenerationTitle=Add Contract input
rootContractInputName=Input name
......@@ -56,7 +57,7 @@ inputType=Input type
attributetype=Attribute type
atLeastOneAttributeShouldBeSelectedError=At least one attribute should be checked.
attributeName = Attribute name
warningAddFromData_noDataAvailable=Please create first a business variable from Data view.
warningAddFromData_noDataAvailable=Please create first a business variable from Data view or a document from Document view.
warningAddFromData_noDataSelected=Please select a business variable in the list.
reminderForStepMessage=From the contract definition, the Studio can automatically generate operations to store or update business variables.\nYou can then modify these operations if necessary.
reminderForProcessMessage=From the contract definition, the Studio can automatically generate scripts to initialize business variables.
......@@ -85,3 +86,11 @@ preview=Preview >
selectMandatories=Mandatory attributes
mandatoryFieldsNotSelectedWarning=Mandatory attribute(s) {0} is/are not selected. Either select it/them or initialize it/them manually.
mandatoryFieldsNotSelectedStepWarning=Mandatory attribute(s) {0} is/are not selected. Either select it/them or create storage and update operations.
businessVariable=Business variable
document=Document
warningAddFromData_noDocumentSelected=Please create first a document from document view.
warningAddFromData_noDocumentAvailable=Please select a Document in the list.
defaultValueAlreadyDefinedWarning=The document {0} is already initialized. Create input from this document will overwrite the current value of {0} by the value of contract input.
fileInputType=of type FILE
openUpdateDocumentOperationWarningTitle=Update document operation generation
openUpdateDocumentOperationWarningMessages=The contract input have been specified. Operations to set the value of document {0} with the contract input value will be generated. It can be viewed in the Operations pane.\nIf operation has already been generated for this input, it will not be replaced.
\ No newline at end of file
......@@ -15,7 +15,10 @@
package org.bonitasoft.studio.contract.ui.property;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.process.builders.BusinessObjectDataBuilder.aBusinessData;
import static org.bonitasoft.studio.model.process.builders.ContractBuilder.aContract;
import static org.bonitasoft.studio.model.process.builders.DataBuilder.aData;
import static org.bonitasoft.studio.model.process.builders.DocumentBuilder.aDocument;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import static org.bonitasoft.studio.model.process.builders.TaskBuilder.aTask;
import static org.mockito.Matchers.anyString;
......@@ -29,6 +32,7 @@ import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.contract.core.mapping.expression.FieldToContractInputMappingExpressionBuilder;
import org.bonitasoft.studio.contract.core.mapping.operation.FieldToContractInputMappingOperationBuilder;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.data.ui.property.section.PoolAdaptableSelectionProvider;
import org.bonitasoft.studio.designer.ui.contribution.CreateAndEditFormContributionItem;
import org.bonitasoft.studio.model.process.Contract;
import org.bonitasoft.studio.model.process.ContractInput;
......@@ -74,6 +78,9 @@ public class ContractPropertySectionTest {
@Mock
private ContractContainerAdaptableSelectionProvider selectionProvider;
@Mock
private PoolAdaptableSelectionProvider poolSelectionProvider;
@Mock
private CreateAndEditFormContributionItem contributionItem;
......@@ -109,7 +116,8 @@ public class ContractPropertySectionTest {
@Before
public void setUp() throws Exception {
parent = realm.createComposite();
section = spy(new ContractPropertySection(sharedImages, eclipseContext, selectionProvider, repositoryAccessor, operationBuilder, expressionBuilder,
section = spy(new ContractPropertySection(sharedImages, eclipseContext, selectionProvider, poolSelectionProvider, repositoryAccessor, operationBuilder,
expressionBuilder,
progressService));
when(tabbedPropertySheetPage.getWidgetFactory()).thenReturn(new TabbedPropertySheetWidgetFactory());
doReturn(contributionItem).when(section).newContributionItem(CreateAndEditFormContributionItem.class);
......@@ -194,4 +202,34 @@ public class ContractPropertySectionTest {
doReturn(aTask().build()).when(selectionProvider).getAdapter(EObject.class);
assertThat(section.getSectionDescription()).isEqualTo(Messages.stepContractSectionDescription);
}
@Test
public void should_bindGenerateButtonEnablement_convert_boolean_value_to_true_when_pool_contains_business_variable() {
final Pool pool = aPool().havingContract(aContract()).havingData(aBusinessData().build()).build();
section.init(new WritableValue(pool.getContract(), Contract.class));
doReturn(new StructuredSelection(pool)).when(poolSelectionProvider).getSelection();
final Button button = new Button(parent, SWT.PUSH);
section.bindGenerateButtonEnablement(button);
assertThat(button.isEnabled()).isTrue();
}
@Test
public void should_bindGenerateButtonEnablement_convert_return_boolean_value_to_true_when_pool_contains_documents() {
final Pool pool = aPool().havingContract(aContract()).havingDocuments(aDocument().build()).build();
section.init(new WritableValue(pool.getContract(), Contract.class));
doReturn(new StructuredSelection(pool)).when(poolSelectionProvider).getSelection();
final Button button = new Button(parent, SWT.PUSH);
section.bindGenerateButtonEnablement(button);
assertThat(button.isEnabled()).isTrue();
}
@Test
public void should_bindGenerateButtonEnablement_convert_return_boolean_value_to_false_when_pool_contains_no_data() {
final Pool pool = aPool().havingContract(aContract()).havingData(aData().build()).build();
section.init(new WritableValue(pool.getContract(), Contract.class));
doReturn(new StructuredSelection(pool)).when(poolSelectionProvider).getSelection();
final Button button = new Button(parent, SWT.PUSH);
section.bindGenerateButtonEnablement(button);
assertThat(button.isEnabled()).isFalse();
}
}
......@@ -26,13 +26,14 @@ import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelRepositoryStore;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.Document;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.swt.rules.RealmWithDisplay;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.junit.Rule;
import org.junit.Test;
public class BusinessDataSelectedValidatorTest {
public class AvailableDataValidatorTest {
@Rule
public RealmWithDisplay realmWithDisplay = new RealmWithDisplay();
......@@ -47,7 +48,9 @@ public class BusinessDataSelectedValidatorTest {
final BusinessObjectModelRepositoryStore businessObjectStore = mock(BusinessObjectModelRepositoryStore.class);
when(businessObjectStore.getBusinessObjectByQualifiedName(businessObjectData.getClassName())).thenReturn(new BusinessObject());
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, businessObjectStore).validate().isOK()).isTrue();
assertThat(
new AvailableDataValidator(availableBusinessData, selectedDataObservable, new ArrayList<Document>(), businessObjectStore)
.validate().isOK()).isTrue();
}
@Test
......@@ -55,7 +58,8 @@ public class BusinessDataSelectedValidatorTest {
final WritableValue selectedDataObservable = new WritableValue();
final List<Data> availableBusinessData = new ArrayList<Data>();
assertThat(
new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, mock(BusinessObjectModelRepositoryStore.class)).validate()
new AvailableDataValidator(availableBusinessData, selectedDataObservable, new ArrayList<Document>(),
mock(BusinessObjectModelRepositoryStore.class)).validate()
.isOK()).isFalse();
}
......@@ -69,16 +73,21 @@ public class BusinessDataSelectedValidatorTest {
final BusinessObjectModelRepositoryStore businessObjectStore = mock(BusinessObjectModelRepositoryStore.class);
when(businessObjectStore.getBusinessObjectByQualifiedName(businessObjectData.getClassName())).thenReturn(null);
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, businessObjectStore).validate().isOK()).isFalse();
assertThat(
new AvailableDataValidator(availableBusinessData, selectedDataObservable, new ArrayList<Document>(), businessObjectStore)
.validate().isOK()).isFalse();
}
@Test
public void testValidate_KO_forInvalidBusinessDataSelected() throws Exception {
final WritableValue selectedDataObservable = new WritableValue();
final List<Data> availableBusinessData = new ArrayList<Data>();
availableBusinessData.add(ProcessFactory.eINSTANCE.createData());
final BusinessObjectData data = ProcessFactory.eINSTANCE.createBusinessObjectData();
availableBusinessData.add(data);
selectedDataObservable.setValue(data);
assertThat(
new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, mock(BusinessObjectModelRepositoryStore.class)).validate()
new AvailableDataValidator(availableBusinessData, selectedDataObservable, new ArrayList<Document>(),
mock(BusinessObjectModelRepositoryStore.class)).validate()
.isOK()).isFalse();
}
......
......@@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelRepositoryStore;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMapping;
import org.bonitasoft.studio.contract.core.mapping.expression.FieldToContractInputMappingExpressionBuilder;
......@@ -36,7 +37,11 @@ import org.bonitasoft.studio.groovy.ui.viewer.GroovyViewer;
import org.bonitasoft.studio.model.businessObject.BusinessObjectBuilder;
import org.bonitasoft.studio.model.businessObject.FieldBuilder.SimpleFieldBuilder;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.Document;
import org.bonitasoft.studio.model.process.DocumentType;
import org.bonitasoft.studio.model.process.Pool;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.Task;
import org.bonitasoft.studio.model.process.provider.ProcessItemProviderAdapterFactory;
import org.bonitasoft.studio.swt.rules.RealmWithDisplay;
......@@ -101,7 +106,7 @@ public class ContractInputGenerationWizardTest {
expressionBuilder, preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
assertThat(wizard.getPages()[0]).isInstanceOf(SelectBusinessDataWizardPage.class);
assertThat(wizard.getPages()[0]).isInstanceOf(SelectDataWizardPage.class);
}
@Test
......@@ -114,7 +119,7 @@ public class ContractInputGenerationWizardTest {
expressionBuilder, preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
assertThat(wizard.getPages()[0]).isInstanceOf(SelectBusinessDataWizardPage.class);
assertThat(wizard.getPages()[0]).isInstanceOf(SelectDataWizardPage.class);
}
@Test
......@@ -131,7 +136,7 @@ public class ContractInputGenerationWizardTest {
when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class))).thenReturn(groovyViewer);
when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
when(groovyViewer.getDocument()).thenReturn(document);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
......@@ -141,8 +146,7 @@ public class ContractInputGenerationWizardTest {
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.performFinish();
assertThat(process.getContract().getInputs()).extracting("name").contains("employeeInput");
assertThat(process.getContract().getInputs()).extracting("name").contains("employee_input");
assertThat(process.getContract().getInputs().get(0).getInputs()).extracting("name").contains("firstName");
}
......@@ -151,7 +155,7 @@ public class ContractInputGenerationWizardTest {
final BusinessObjectData data = aBusinessData().withName("employee").withClassname("org.company.Employee").build();
final Pool process = aPool().havingContract(aContract()).build();
process.getData().add(data);
final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
when(store.getBusinessObjectByQualifiedName("org.company.Employee")).thenReturn(
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
......@@ -192,7 +196,7 @@ public class ContractInputGenerationWizardTest {
when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class))).thenReturn(groovyViewer);
when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
when(groovyViewer.getDocument()).thenReturn(document);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
......@@ -220,7 +224,7 @@ public class ContractInputGenerationWizardTest {
BusinessObjectBuilder.aBO("org.company.Employee").withField(SimpleFieldBuilder.aStringField("firstName").build()).build());
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(store);
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
......@@ -251,12 +255,12 @@ public class ContractInputGenerationWizardTest {
when(preferenceStore.getString(ContractInputGenerationInfoDialogFactory.SHOW_GENERATION_SUCCESS_DIALOG)).thenReturn("always");
when(operationBuilder.toOperation(any(BusinessObjectData.class), any(FieldToContractInputMapping.class))).thenReturn(
anOperation().build());
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
......@@ -266,22 +270,71 @@ public class ContractInputGenerationWizardTest {
assertThat(task.getOperations().isEmpty()).isFalse();
}
@Test
public void should_add_DocumentUpdateOperation_whenDataIsDocument_onFinish() {
final Task task = aTask().havingContract(aContract()).build();
final Pool process = aPool().havingContract(aContract()).build();
final Document document1 = ProcessFactory.eINSTANCE.createDocument();
document1.setName("myDocument");
process.getDocuments().add(document1);
process.getElements().add(task);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(task, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.performFinish();
assertThat(task.getContract().getInputs().get(0).getType()).isEqualTo(ContractInputType.FILE);
assertThat(task.getOperations().get(0).getLeftOperand().getName()).isEqualTo("myDocument");
assertThat(task.getOperations().get(0).getRightOperand().getType()).isEqualTo(ExpressionConstants.CONTRACT_INPUT_TYPE);
assertThat(task.getOperations().get(0).getRightOperand().getName()).isEqualTo("myDocument_doc_input");
}
@Test
public void should_add_FileInput_whenDataIsDocument_onFinish() {
final Pool process = aPool().havingContract(aContract()).build();
process.getDocuments().add(ProcessFactory.eINSTANCE.createDocument());
when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class))).thenReturn(groovyViewer);
when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
when(groovyViewer.getDocument()).thenReturn(document);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder,
preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
wizard.performFinish();
assertThat(process.getContract().getInputs().get(0).getType()).isEqualTo(ContractInputType.FILE);
assertThat(process.getDocuments().get(0).getDocumentType()).isEqualTo(DocumentType.CONTRACT);
}
@Test
public void should_canFinish_return_false_when_no_data_is_defined() {
final Pool process = aPool().havingContract(aContract()).build();
when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class))).thenReturn(groovyViewer);
when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
when(groovyViewer.getDocument()).thenReturn(document);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
assertThat(wizard.canFinish()).isFalse();
}
......@@ -290,7 +343,7 @@ public class ContractInputGenerationWizardTest {
final Pool process = aPool().havingContract(aContract()).build();
final BusinessObjectData data = aBusinessData().withClassname("com.company.Employee").build();
process.getData().add(data);
final BusinessObjectModelRepositoryStore store = mock(BusinessObjectModelRepositoryStore.class);
Mockito.doReturn(BusinessObjectBuilder.aBO("com.company.Employee").withField(SimpleFieldBuilder.aTextField("name").build()).build()).when(store)
.getBusinessObjectByQualifiedName("com.company.Employee");
......@@ -298,16 +351,16 @@ public class ContractInputGenerationWizardTest {
when(sourceViewerFactory.createSourceViewer(any(Composite.class), any(Boolean.class))).thenReturn(groovyViewer);
when(groovyViewer.getSourceViewer()).thenReturn(sourceViewer);
when(groovyViewer.getDocument()).thenReturn(document);
final ContractInputGenerationWizard wizard = new ContractInputGenerationWizard(process, editingDomain(), repositoryAccessor, operationBuilder,
expressionBuilder, preferenceStore, sharedImages, dialogFactory, new ContractInputGenerationWizardPagesFactory(), sourceViewerFactory);
wizard.addPages();
final IWizardContainer wizardContainer = Mockito.mock(IWizardContainer.class);
when(wizardContainer.getShell()).thenReturn(realmWithDisplay.getShell());
wizard.setContainer(wizardContainer);
wizard.createPageControls(realmWithDisplay.createComposite());
assertThat(wizard.canFinish()).isTrue();
}
......
......@@ -68,7 +68,7 @@ public class CreateContractInputFromBusinessObjectWizardPageTest {
rootNameObservable.setValue("employeeInput");
final WritableList fieldToContractInputMappingsObservable = new WritableList();
final CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(contract, options,
selectedDataObservable, rootNameObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
selectedDataObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
final FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(Mockito.mock(RelationField.class));
final SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
final SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
......@@ -100,7 +100,7 @@ public class CreateContractInputFromBusinessObjectWizardPageTest {
rootNameObservable.setValue("employeeInput");
final WritableList fieldToContractInputMappingsObservable = new WritableList();
final CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(contract, options,
selectedDataObservable, rootNameObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
selectedDataObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
final FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(Mockito.mock(RelationField.class));
final SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
final SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
......@@ -132,7 +132,7 @@ public class CreateContractInputFromBusinessObjectWizardPageTest {
rootNameObservable.setValue("employeeInput");
final WritableList fieldToContractInputMappingsObservable = new WritableList();
final CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(contract, options,
selectedDataObservable, rootNameObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
selectedDataObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
final FieldToContractInputMapping rootMapping1 = new RelationFieldToContractInputMapping(Mockito.mock(RelationField.class));
final SimpleFieldToContractInputMapping childMapping1 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
final SimpleFieldToContractInputMapping childMapping2 = new SimpleFieldToContractInputMapping(Mockito.mock(SimpleField.class));
......@@ -162,7 +162,7 @@ public class CreateContractInputFromBusinessObjectWizardPageTest {
rootNameObservable.setValue("employeeInput");
final WritableList fieldToContractInputMappingsObservable = new WritableList();
final CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(contract, options,
selectedDataObservable, rootNameObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
selectedDataObservable, new FieldToContractInputMappingFactory(), fieldToContractInputMappingsObservable, store);
final RelationField rootField1 = Mockito.mock(RelationField.class);
final RelationField rootField2 = Mockito.mock(RelationField.class);
final SimpleField childField1 = Mockito.mock(SimpleField.class);
......