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

fix(perf) improve bo to contract perf (#296)

closes BS-16238
parent fb235e41
......@@ -24,7 +24,6 @@ import org.bonitasoft.studio.connector.model.definition.wizard.AbstractConnector
import org.bonitasoft.studio.connector.model.definition.wizard.PageComponentSwitchBuilder;
import org.bonitasoft.studio.expression.editor.viewer.CheckBoxExpressionViewer;
import org.bonitasoft.studio.expression.editor.viewer.ExpressionViewer;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
......@@ -72,11 +71,11 @@ public class CustomUserInfoConnectorConfigurationWizardPage extends AbstractConn
final Composite valueComposite = createComposite(cuiComposite, 2, 0);
final ExpressionViewer valueViewer = componentSwitchBuilder.createTextControl(valueComposite, cuiValueInput);
valueViewer.setMessage(Messages.typeValueToFilter, IStatus.INFO);
valueViewer.setMessage(Messages.typeValueToFilter);
componentSwitchBuilder.createCheckboxControl(valueComposite, cuiPartialMatchInput);
final CheckBoxExpressionViewer viewer = componentSwitchBuilder.createCheckboxControl(pageComposite, automaticAssignInput);
viewer.setMessage(Messages.assignOnlyIfOneUser, IStatus.INFO);
viewer.setMessage(Messages.assignOnlyIfOneUser);
return mainComposite;
}
......
......@@ -54,7 +54,6 @@ import org.bonitasoft.studio.model.expression.TableExpression;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EObject;
......@@ -171,7 +170,7 @@ public class PageComponentSwitchBuilder {
private void handleDescription(final Text object, final ExpressionViewer viewer) {
final String desc = messageProvider.getFieldDescription(definition, object.getId());
if (desc != null && !desc.isEmpty()) {
viewer.setMessage(desc, IStatus.INFO);
viewer.setMessage(desc);
}
}
......@@ -289,7 +288,7 @@ public class PageComponentSwitchBuilder {
viewer.setInput(parameter);
final String desc = getDescription(object.getId());
if (desc != null && !desc.isEmpty()) {
viewer.setMessage(desc, IStatus.INFO);
viewer.setMessage(desc);
}
if (((Expression) parameter.getExpression()).getName() == null) {
final Expression falseExp = (Expression) parameter.getExpression();
......@@ -422,7 +421,7 @@ public class PageComponentSwitchBuilder {
viewer.setInput(parameter);
final String desc = getDescription(object.getId());
if (desc != null && !desc.isEmpty()) {
viewer.setMessage(desc, IStatus.INFO);
viewer.setMessage(desc);
}
context.bindValue(ViewersObservables.observeSingleSelection(viewer),
EMFObservables.observeValue(parameter,
......@@ -613,7 +612,7 @@ public class PageComponentSwitchBuilder {
viewer.setInput(parameter);
final String desc = getDescription(object.getId());
if (desc != null && !desc.isEmpty()) {
viewer.setMessage(desc, IStatus.INFO);
viewer.setMessage(desc);
}
context.bindValue(ViewersObservables.observeSingleSelection(viewer),
EMFObservables.observeValue(parameter,
......
......@@ -26,7 +26,7 @@ import org.bonitasoft.studio.common.jface.TableColumnSorter;
import org.bonitasoft.studio.connector.model.definition.Output;
import org.bonitasoft.studio.connectors.ConnectorPlugin;
import org.bonitasoft.studio.connectors.i18n.Messages;
import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.expression.editor.ExpressionProviderService;
import org.bonitasoft.studio.expression.editor.provider.IExpressionEditor;
import org.bonitasoft.studio.expression.editor.provider.IExpressionProvider;
import org.bonitasoft.studio.expression.editor.provider.SelectionAwareExpressionEditor;
......@@ -162,7 +162,7 @@ public class ConnectorOutputExpressionEditor extends SelectionAwareExpressionEdi
ExpressionViewer expressionViewer) {
this.inputExpression = inputExpression;
Set<Output> input = new HashSet<Output>();
IExpressionProvider provider = ExpressionEditorService.getInstance().getExpressionProvider(ExpressionConstants.CONNECTOR_OUTPUT_TYPE);
IExpressionProvider provider = ExpressionProviderService.getInstance().getExpressionProvider(ExpressionConstants.CONNECTOR_OUTPUT_TYPE);
for (Expression e : provider.getExpressions(context)) {
if (inputExpression.isReturnTypeFixed()) {
if (e.getReturnType().equals(inputExpression.getReturnType())) {
......
......@@ -32,7 +32,6 @@ import org.bonitasoft.studio.model.expression.AbstractExpression;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
......@@ -84,7 +83,7 @@ public class GroovyScriptConfigurationWizardPage extends AbstractConnectorConfig
viewer.setInput(parameter);
final String desc = builder.getDescription(SCRIPT_INPUT_NAME);
if (desc != null && !desc.isEmpty()) {
viewer.setMessage(desc, IStatus.INFO);
viewer.setMessage(desc);
}
context.bindValue(ViewersObservables.observeSingleSelection(viewer),
EMFObservables.observeValue(parameter, ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION));
......
......@@ -76,7 +76,7 @@ AbstractConnectorOutputWizardPage {
outputExpressionViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).create());
outputExpressionViewer.addFilter(connectorOutputFilter);
outputExpressionViewer.setContext(getConnector());
outputExpressionViewer.setMessage(Messages.connectorExpressionViewerMessage, IStatus.INFO);
outputExpressionViewer.setMessage(Messages.connectorExpressionViewerMessage);
outputExpressionViewer.setExternalDataBindingContext(context);
outputExpressionViewer.setInput(output);
outputExpressionViewer.addExpressionValidator(new IExpressionValidator() {
......
......@@ -174,7 +174,7 @@ public class TestDatabaseConnectorOutputWizardPage extends DatabaseConnectorOutp
outputExpressionViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).create());
outputExpressionViewer.addFilter(rightFilter);
outputExpressionViewer.setContext(getConnector());
outputExpressionViewer.setMessage(Messages.connectorExpressionViewerMessage, IStatus.INFO);
outputExpressionViewer.setMessage(Messages.connectorExpressionViewerMessage);
outputExpressionViewer.setExternalDataBindingContext(context);
outputExpressionViewer.setProposalsFiltering(false);
outputExpressionViewer.addExpressionValidator(new IExpressionValidator() {
......
......@@ -94,4 +94,6 @@ openUpdateDocumentOperationWarningTitle=Update document operation generation
openUpdateDocumentOperationWarningMessages=The contract input has been specified. The operation to set the value of document {0} with the contract input value will be generated. It can be viewed in the Operations pane.\nIf the operation has already been generated for this input, it will not be replaced.
updateInitialDocumentContentWarningTitle=Update document initial content
updateInitialDocumentContentWarningMsg=The contract input has been specified. The initial content of the document "%s" will be set. It can be viewed by opening the document in the Data pane. If the initial content has already been set, it will be replaced.\nThe contract input can be edited manually.
longConversionWarning=Due to inter-operability issue between Java Long type and numeric JavaScript type you should not have Long contract input if you plan to start your process using a form.\nLong in contract is recommended for processes started by call activities or programmatically in Java.
\ No newline at end of file
longConversionWarning=Due to inter-operability issue between Java Long type and numeric JavaScript type you should not have Long contract input if you plan to start your process using a form.\nLong in contract is recommended for processes started by call activities or programmatically in Java.
creatingMappingOperation=Creating mapping operation for %s
saving=Saving...
\ No newline at end of file
......@@ -38,6 +38,8 @@ import org.bonitasoft.studio.model.businessObject.FieldBuilder.SimpleFieldBuilde
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.assertions.ContractInputAssert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
......@@ -49,10 +51,11 @@ public class RootContractInputGeneratorTest {
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
Collections.<FieldToContractInputMapping> emptyList(), repositoryAccessor, mock(FieldToContractInputMappingOperationBuilder.class),
Collections.<FieldToContractInputMapping> emptyList(), repositoryAccessor,
mock(FieldToContractInputMappingOperationBuilder.class),
mock(FieldToContractInputMappingExpressionBuilder.class));
rootContractInputGenerator.build(aBusinessData().build());
rootContractInputGenerator.build(aBusinessData().build(), new NullProgressMonitor());
ContractInputAssert.assertThat(rootContractInputGenerator.getRootContractInput()).hasName("rootInputName")
.hasType(ContractInputType.COMPLEX);
......@@ -60,70 +63,82 @@ public class RootContractInputGeneratorTest {
@Test
public void should_create_a_complex_contract_input_with_generated_child_input_from_mapping() throws Exception {
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"input2").build());
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"input2").build());
notGeneratedMapping.setGenerated(false);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(notGeneratedMapping, new SimpleFieldToContractInputMapping(SimpleFieldBuilder
.aStringField("input1").build())), repositoryAccessor, mock(FieldToContractInputMappingOperationBuilder.class),
.aStringField("input1").build())),
repositoryAccessor, mock(FieldToContractInputMappingOperationBuilder.class),
mock(FieldToContractInputMappingExpressionBuilder.class));
rootContractInputGenerator.build(aBusinessData().build());
rootContractInputGenerator.build(aBusinessData().build(), new NullProgressMonitor());
assertThat(rootContractInputGenerator.getRootContractInput().getInputs()).hasSize(1);
}
@Test
public void should_create_operation_for_given_business_data_and_generated_contract_input() throws Exception {
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"firstName").build());
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"firstName").build());
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName", newArrayList(mapping),
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(mapping),
repositoryAccessor, operationBuilder, mock(FieldToContractInputMappingExpressionBuilder.class));
final BusinessObjectData businessObjectData = aBusinessData().withName("employee").build();
rootContractInputGenerator.build(businessObjectData);
final IProgressMonitor monitor = new NullProgressMonitor();
rootContractInputGenerator.build(businessObjectData, monitor);
verify(operationBuilder).toOperation(businessObjectData, mapping);
verify(operationBuilder).toOperation(businessObjectData, mapping, monitor);
}
@Test
public void should_allAttributesGenerated_setToFalse_whenNotAllMappingAreGenerated() throws OperationCreationException {
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"input1").build());
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"input1").build());
notGeneratedMapping.setGenerated(false);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName", newArrayList(notGeneratedMapping),
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(notGeneratedMapping),
repositoryAccessor, operationBuilder, mock(FieldToContractInputMappingExpressionBuilder.class));
final BusinessObjectData businessObjectData = aBusinessData().withName("employee").build();
rootContractInputGenerator.build(businessObjectData);
rootContractInputGenerator.build(businessObjectData, new NullProgressMonitor());
assertThat(rootContractInputGenerator.isAllAttributesGenerated()).isFalse();
}
@Test
public void should_allAttributesGenerated_setTotrue_whenAllMappingAreGenerated() throws OperationCreationException {
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"input2").build());
final SimpleFieldToContractInputMapping notGeneratedMapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"input2").build());
notGeneratedMapping.setGenerated(true);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName", newArrayList(notGeneratedMapping,
new SimpleFieldToContractInputMapping(SimpleFieldBuilder
.aStringField("input1").build())),
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(notGeneratedMapping,
new SimpleFieldToContractInputMapping(SimpleFieldBuilder
.aStringField("input1").build())),
repositoryAccessor, operationBuilder, mock(FieldToContractInputMappingExpressionBuilder.class));
final BusinessObjectData businessObjectData = aBusinessData().withName("employee").build();
rootContractInputGenerator.build(businessObjectData);
rootContractInputGenerator.build(businessObjectData, new NullProgressMonitor());
assertThat(rootContractInputGenerator.isAllAttributesGenerated()).isTrue();
}
......@@ -136,15 +151,21 @@ public class RootContractInputGeneratorTest {
final BusinessObject bo = aBO("org.test.Employee").withField(firstNameField).build();
when(businessObjectStore.getBusinessObjectByQualifiedName("org.test.Employee")).thenReturn(bo);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessObjectStore);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("employeesInput", newArrayList(mapping),
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class))
.thenReturn(businessObjectStore);
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("employeesInput",
newArrayList(mapping),
repositoryAccessor, operationBuilder, mock(FieldToContractInputMappingExpressionBuilder.class));
final BusinessObjectData businessObjectData = aBusinessData().withName("employees").withClassname("org.test.Employee").multiple().build();
rootContractInputGenerator.build(businessObjectData);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor.forClass(FieldToContractInputMapping.class);
verify(operationBuilder).toOperation(eq(businessObjectData), argumentCaptor.capture());
final BusinessObjectData businessObjectData = aBusinessData().withName("employees")
.withClassname("org.test.Employee").multiple().build();
final NullProgressMonitor monitor = new NullProgressMonitor();
rootContractInputGenerator.build(businessObjectData, monitor);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor
.forClass(FieldToContractInputMapping.class);
verify(operationBuilder).toOperation(eq(businessObjectData), argumentCaptor.capture(), eq(monitor));
final Field field = argumentCaptor.getValue().getField();
assertThat(field).isInstanceOf(RelationField.class);
assertThat(field.getName()).isEqualTo("employeesInput");
......@@ -154,21 +175,27 @@ public class RootContractInputGeneratorTest {
}
@Test
public void should_create_initilal_value_expression_for_given_business_data_and_generated_contract_input() throws Exception {
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"firstName").build());
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
public void should_create_initilal_value_expression_for_given_business_data_and_generated_contract_input()
throws Exception {
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"firstName").build());
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final FieldToContractInputMappingExpressionBuilder expressionBuilder = mock(FieldToContractInputMappingExpressionBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName", newArrayList(mapping),
final FieldToContractInputMappingExpressionBuilder expressionBuilder = mock(
FieldToContractInputMappingExpressionBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(mapping),
repositoryAccessor, operationBuilder, expressionBuilder);
final BusinessObjectData businessObjectData = aBusinessData().withName("employee").build();
rootContractInputGenerator.build(businessObjectData);
rootContractInputGenerator.build(businessObjectData, new NullProgressMonitor());
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor.forClass(FieldToContractInputMapping.class);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor
.forClass(FieldToContractInputMapping.class);
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture(), eq(false));
final FieldToContractInputMapping fieldToContractInputMapping = argumentCaptor.getValue();
assertThat(fieldToContractInputMapping.getField().getName()).isEqualTo("rootInputName");
......@@ -177,21 +204,27 @@ public class RootContractInputGeneratorTest {
}
@Test
public void should_create_initilal_value_expression_for_given_multiple_business_data_and_generated_contract_input() throws Exception {
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(SimpleFieldBuilder.aStringField(
"firstName").build());
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(FieldToContractInputMappingOperationBuilder.class);
public void should_create_initilal_value_expression_for_given_multiple_business_data_and_generated_contract_input()
throws Exception {
final SimpleFieldToContractInputMapping mapping = new SimpleFieldToContractInputMapping(
SimpleFieldBuilder.aStringField(
"firstName").build());
final FieldToContractInputMappingOperationBuilder operationBuilder = mock(
FieldToContractInputMappingOperationBuilder.class);
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final BusinessObjectModelRepositoryStore businessStore = mock(BusinessObjectModelRepositoryStore.class);
when(repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class)).thenReturn(businessStore);
final FieldToContractInputMappingExpressionBuilder expressionBuilder = mock(FieldToContractInputMappingExpressionBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName", newArrayList(mapping),
final FieldToContractInputMappingExpressionBuilder expressionBuilder = mock(
FieldToContractInputMappingExpressionBuilder.class);
final RootContractInputGenerator rootContractInputGenerator = new RootContractInputGenerator("rootInputName",
newArrayList(mapping),
repositoryAccessor, operationBuilder, expressionBuilder);
final BusinessObjectData businessObjectData = aBusinessData().withName("employee").multiple().build();
rootContractInputGenerator.build(businessObjectData);
rootContractInputGenerator.build(businessObjectData, new NullProgressMonitor());
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor.forClass(FieldToContractInputMapping.class);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor
.forClass(FieldToContractInputMapping.class);
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture(), eq(false));
final FieldToContractInputMapping fieldToContractInputMapping = argumentCaptor.getValue();
assertThat(fieldToContractInputMapping.getField().getName()).isEqualTo("rootInputName");
......
......@@ -35,7 +35,7 @@ import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMapping;
import org.bonitasoft.studio.contract.core.mapping.operation.BusinessObjectInstantiationException;
import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.expression.editor.ExpressionProviderService;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.assertions.ExpressionAssert;
import org.bonitasoft.studio.model.process.BusinessObjectData;
......@@ -55,7 +55,7 @@ public class FieldToContractInputMappingExpressionBuilderTest {
@Mock
private RepositoryAccessor repositoryAccessor;
@Mock
private ExpressionEditorService expressionEditorService;
private ExpressionProviderService expressionEditorService;
@Mock
private GroovyCompilationUnit groovyCompilationUnit;
......
......@@ -41,13 +41,14 @@ 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;
import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.expression.editor.ExpressionProviderService;
import org.bonitasoft.studio.expression.editor.filter.ExpressionReturnTypeFilter;
import org.bonitasoft.studio.model.expression.Operation;
import org.bonitasoft.studio.model.expression.assertions.ExpressionAssert;
import org.bonitasoft.studio.model.expression.assertions.OperatorAssert;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
......@@ -66,7 +67,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
@Mock
private RepositoryAccessor repositoryAccessor;
@Mock
private ExpressionEditorService expressionEditorService;
private ExpressionProviderService expressionEditorService;
@Mock
private FieldToContractInputMappingExpressionBuilder expressionBuilder;
......@@ -76,7 +77,8 @@ public class FieldToContractInputMappingOperationBuilderTest {
}
@Test
public void should_create_an_operation_for_a_given_simple_contact_input_and_a_primitive_business_data_field() throws Exception {
public void should_create_an_operation_for_a_given_simple_contact_input_and_a_primitive_business_data_field()
throws Exception {
final FieldToContractInputMappingOperationBuilder inputToOperation = createFixture();
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
......@@ -84,7 +86,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
final BusinessObjectData data = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(data, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(data,
mapping);
mapping, new NullProgressMonitor());
OperatorAssert.assertThat(operation.getOperator())
.hasType(ExpressionConstants.JAVA_METHOD_OPERATOR)
......@@ -100,7 +102,8 @@ public class FieldToContractInputMappingOperationBuilderTest {
}
@Test
public void should_create_an_operation_for_a_given_complex_contact_input_and_a_primitive_business_data_field() throws Exception {
public void should_create_an_operation_for_a_given_complex_contact_input_and_a_primitive_business_data_field()
throws Exception {
final FieldToContractInputMappingOperationBuilder inputToOperation = createFixture();
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
......@@ -111,7 +114,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
final BusinessObjectData data = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(data, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(data,
mapping);
mapping, new NullProgressMonitor());
OperatorAssert.assertThat(operation.getOperator())
.hasType(ExpressionConstants.JAVA_METHOD_OPERATOR)
......@@ -126,7 +129,8 @@ public class FieldToContractInputMappingOperationBuilderTest {
}
@Test
public void should_create_an_operation_for_a_given_complex_contact_input_and_a_composite_reference_business_data_field() throws Exception {
public void should_create_an_operation_for_a_given_complex_contact_input_and_a_composite_reference_business_data_field()
throws Exception {
final FieldToContractInputMappingOperationBuilder inputToOperation = createFixture();
final RelationField address = aCompositionField("address", aBO("Address").build());
......@@ -135,7 +139,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
final BusinessObjectData businessObjectData = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(businessObjectData, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(businessObjectData,
mapping);
mapping, new NullProgressMonitor());
OperatorAssert.assertThat(operation.getOperator())
.hasType(ExpressionConstants.JAVA_METHOD_OPERATOR)
......@@ -154,11 +158,12 @@ public class FieldToContractInputMappingOperationBuilderTest {
final FieldToContractInputMappingOperationBuilder inputToOperation = createFixture();
when(expressionReturnTypeFilter.compatibleReturnTypes(anyString(), anyString())).thenReturn(false);
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class), anyBoolean())).thenReturn(
anExpression().build());
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class),
anyBoolean())).thenReturn(
anExpression().build());
thrown.expect(OperationCreationException.class);
inputToOperation.toOperation(aBusinessData().withName("myEmployee").build(),
aSimpleMapping(lastNameField).build());
aSimpleMapping(lastNameField).build(), new NullProgressMonitor());
}
@Test
......@@ -172,11 +177,12 @@ public class FieldToContractInputMappingOperationBuilderTest {
final MappingOperationScriptBuilder fakeScriptBuilder = mock(MappingOperationScriptBuilder.class);
when(fakeScriptBuilder.toScript()).thenThrow(BusinessObjectInstantiationException.class);
doReturn(fakeScriptBuilder).when(mapping).getScriptBuilder(any(BusinessObjectData.class));
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class), anyBoolean())).thenReturn(
anExpression().build());
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class),
anyBoolean())).thenReturn(
anExpression().build());
thrown.expect(OperationCreationException.class);
inputToOperation.toOperation(aBusinessData().withName("myEmployee").build(),
mapping);
mapping, new NullProgressMonitor());
}
@Test
......@@ -185,10 +191,11 @@ public class FieldToContractInputMappingOperationBuilderTest {
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
final FieldToContractInputMapping mapping = aSimpleMapping(lastNameField).build();
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class), anyBoolean())).thenReturn(
anExpression().build());
when(expressionBuilder.toExpression(any(BusinessObjectData.class), any(FieldToContractInputMapping.class),
anyBoolean())).thenReturn(
anExpression().build());
final Operation operation = inputToOperation.toOperation(aBusinessData().multiple().withName("employees").build(),
mapping);
mapping, new NullProgressMonitor());
OperatorAssert.assertThat(operation.getOperator())
.hasType(ExpressionConstants.JAVA_METHOD_OPERATOR)
......
......@@ -67,14 +67,20 @@ public class CreateContractInputFromBusinessObjectWizardPageTest {
final WritableValue rootNameObservable = new WritableValue();
rootNameObservable.setValue("employeeInput");
final WritableList fieldToContractInputMappingsObservable = new WritableList();
final CreateContractInputFromBusinessObjectWizardPage page = new CreateContractInputFromBusinessObjectWizardPage(contract, options,