Commit b49e3905 authored by Aurelien Pupier's avatar Aurelien Pupier

Merge remote-tracking branch 'origin/7.1.x' into MasterBugFixing

Conflicts:
	translations/it/org.bonitasoft.studio.contract.nl_it/messages_it.properties
	translations/it/org.bonitasoft.studio.validation.nl_it/messages_it.properties
parents 177451a7 65ea7842
contractSectionDescription=Define a contract for this step or pool instantiation.
processContractSectionDescription=A contract defines the information that a process requires for instantiation.\nAfter you have defined the contract, you can generate the form by clicking the UI designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the process instantiation inputs. You must handle constraints with validation in the form.\nYou can use contract input values as the initial value of variables, documents and search keys or in connectors in (on enter).
stepContractSectionDescription=A contract defines the information that a task requires to execute. If inputs are missing or constraints are not fulfilled on form submission, the task is not executed and stays ready.\nAfter you have defined the contract, you can generate the form by clicking the UI designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the task inputs. You must handle constraints with validation in the form.\nYou can use a contract input value in operations and connectors out (on finish).
processContractSectionDescription=A contract defines the information that a process requires for instantiation.\nAfter you have defined the contract, you can generate the form by clicking the UI Designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the process instantiation inputs. You must handle constraints with validation in the form.\nYou can use contract input values as the initial value of variables, documents and search keys or in connectors in (on enter).
stepContractSectionDescription=A contract defines the information that a task requires to execute. If inputs are missing or constraints are not fulfilled on form submission, the task is not executed and stays ready.\nAfter you have defined the contract, you can generate the form by clicking the UI Designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the task inputs. You must handle constraints with validation in the form.\nYou can use a contract input value in operations and connectors out (on finish).
name=Name
type=Type
mandatory=Mandatory
......@@ -72,4 +72,5 @@ autoGeneratedOperationStepButton=Auto-generate storage operations
manuallyDefinedOperationStepButton=No, thanks. I'll manually define how to use the contract.
autoGeneratedOperationProcessButton=Auto-generate the initialization script
manuallyDefinedOperationProcessButton=No, thanks. I'll manually define how to use the contract.
contractStrictGenerationMsg=The contract inputs have been specified.\nA script that sets the default values of the business variable attributes with the contract input values will be generated. It can be viewed and edited in the Data tab. If the default value of a business variable already exists, this script will override it.\n\nContract inputs and the script can be edited manually.\nHowever, there is no refactoring (for example, updating the attribute name or a multiple property in a business object or contract element will break the script).
\ No newline at end of file
contractStrictGenerationMsg=The contract inputs have been specified.\nA script that sets the default values of the business variable attributes with the contract input values will be generated. It can be viewed and edited in the Data tab. If the default value of a business variable already exists, this script will override it.\n\nContract inputs and the script can be edited manually.\nHowever, there is no refactoring (for example, updating the attribute name or a multiple property in a business object or contract element will break the script).
invalidBusinessDataSelected=Invalid business data selected.
\ No newline at end of file
/**
* Copyright (C) 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
* (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.contract.core.mapping.operation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.businessObject.BusinessObjectBuilder.aBO;
import org.junit.Test;
public class VariableNameResolverTest {
@Test
public void should_create_a_variable_name_for_a_business_object() throws Exception {
final VariableNameResolver variableNameResolver = new VariableNameResolver();
final String varName = variableNameResolver.newVarName(aBO("org.test.Employee").build());
assertThat(varName).isEqualTo("employeeVar");
}
@Test
public void should_create_a_variable_name_for_a_business_object_with_suffix_if_variable_is_already_in_the_context() throws Exception {
final VariableNameResolver variableNameResolver = new VariableNameResolver();
final String varName = variableNameResolver.newVarName(aBO("org.test.Employee").build());
final String varName2 = variableNameResolver.newVarName(aBO("org.test.Employee").build());
final String varName3 = variableNameResolver.newVarName(aBO("org.test.Employee").build());
assertThat(varName).isEqualTo("employeeVar");
assertThat(varName2).isEqualTo("employeeVar2");
assertThat(varName3).isEqualTo("employeeVar3");
}
@Test
public void should_create_a_list_variable_name_for_a_business_object() throws Exception {
final VariableNameResolver variableNameResolver = new VariableNameResolver();
final String varName = variableNameResolver.newListVarName(aBO("org.test.Employee").build());
assertThat(varName).isEqualTo("employeeList");
}
@Test
public void should_create_a_list_variable_name_for_a_business_object_with_suffix_if_variable_is_already_in_the_context() throws Exception {
final VariableNameResolver variableNameResolver = new VariableNameResolver();
final String varName = variableNameResolver.newListVarName(aBO("org.test.Employee").build());
final String varName2 = variableNameResolver.newListVarName(aBO("org.test.Employee").build());
final String varName3 = variableNameResolver.newListVarName(aBO("org.test.Employee").build());
assertThat(varName).isEqualTo("employeeList");
assertThat(varName2).isEqualTo("employeeList2");
assertThat(varName3).isEqualTo("employeeList3");
}
}
......@@ -19,6 +19,7 @@ import static org.bonitasoft.studio.model.businessObject.BusinessObjectBuilder.a
import static org.bonitasoft.studio.model.businessObject.FieldBuilder.anAggregationField;
import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.aContractInput;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.junit.Test;
public class AggregationReferencePropertyInitializerTest {
......@@ -27,7 +28,7 @@ public class AggregationReferencePropertyInitializerTest {
public void should_call_query_in_a_closure() throws Exception {
final AggregationReferencePropertyInitializer propertyInitializer = new AggregationReferencePropertyInitializer(null, anAggregationField("country",
aBO("country").build()), aContractInput().withName("persistenceId").in(aContractInput().withName("country")).build(),
"");
"", new VariableNameResolver());
final String initialValue = propertyInitializer.getInitialValue();
......
......@@ -20,6 +20,7 @@ import static org.bonitasoft.studio.model.businessObject.FieldBuilder.aStringFie
import static org.bonitasoft.studio.model.businessObject.FieldBuilder.anAggregationField;
import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.aContractInput;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Rule;
import org.junit.Test;
......@@ -35,7 +36,7 @@ public class BusinessObjectQueryInitializerTest {
final BusinessObjectQueryInitializer initializer = new BusinessObjectQueryInitializer(null, anAggregationField("country", aBO("org.test.Country")
.build()),
aContractInput().withName("countryInput").withType(ContractInputType.COMPLEX).havingInput(aContractInput().withName("persistenceId")).build(),
"myCountry");
"myCountry", new VariableNameResolver());
initializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(null, aStringField("persistenceId").build(),
aContractInput().withName("persistenceId").in(aContractInput().withName("countryInput").withType(ContractInputType.COMPLEX)).build()));
......@@ -59,6 +60,6 @@ public class BusinessObjectQueryInitializerTest {
aContractInput()
.withName("notPersistenceId")
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()).build(),
"myData.employees");
"myData.employees", new VariableNameResolver());
}
}
......@@ -23,6 +23,7 @@ import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.
import org.bonitasoft.engine.bdm.model.field.FieldType;
import org.bonitasoft.engine.bdm.model.field.SimpleField;
import org.bonitasoft.studio.contract.core.mapping.operation.BusinessObjectInstantiationException;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Rule;
import org.junit.Test;
......@@ -37,7 +38,7 @@ public class CompositionReferencePropertyInitializerTest {
public void should_initialize_object_poperty_in_a_closure() throws Exception {
final SimpleField streetField = aSimpleField().withName("street").ofType(FieldType.TEXT).notNullable().build();
final CompositionReferencePropertyInitializer propertyInitializer = new CompositionReferencePropertyInitializer(aCompositionField("address",
aBO("org.test.Address").withField(streetField).build()), aContractInput().build(), "employee.address");
aBO("org.test.Address").withField(streetField).build()), aContractInput().build(), new VariableNameResolver(), "employee.address");
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(null,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX)
......@@ -58,7 +59,7 @@ public class CompositionReferencePropertyInitializerTest {
final CompositionReferencePropertyInitializer propertyInitializer = new CompositionReferencePropertyInitializer(
aCompositionField("address", aBO("org.test.Address").withField(aSimpleField().withName("street").notNullable().build()).build()),
aContractInput().build(),
"employee.address");
new VariableNameResolver(), "employee.address");
thrown.expect(BusinessObjectInstantiationException.class);
propertyInitializer.getInitialValue();
......
......@@ -25,6 +25,7 @@ import org.bonitasoft.engine.bdm.model.field.Field;
import org.bonitasoft.engine.bdm.model.field.FieldType;
import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.engine.bdm.model.field.SimpleField;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Test;
......@@ -44,7 +45,8 @@ public class MultipleAggregationReferencePropertyInitializerTest {
final MultipleAggregationReferencePropertyInitializer initializer = new MultipleAggregationReferencePropertyInitializer(null, employeeBo,
employeesField, aContractInput().withName("persistenceId")
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", false);
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(),
"emp", new VariableNameResolver(), false);
final String initialValue = initializer.getInitialValue();
......@@ -77,7 +79,8 @@ public class MultipleAggregationReferencePropertyInitializerTest {
final MultipleAggregationReferencePropertyInitializer initializer = new MultipleAggregationReferencePropertyInitializer(null, employeeBo,
employeesField, aContractInput().withName("persistenceId")
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", true);
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(),
"emp", new VariableNameResolver(), true);
final String initialValue = initializer.getInitialValue();
......@@ -112,7 +115,8 @@ public class MultipleAggregationReferencePropertyInitializerTest {
employeesField,
aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()
.havingInput(aContractInput().withName("persistenceId"))
.in(aContractInput().withName("direcotries").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", false);
.in(aContractInput().withName("direcotries").withType(ContractInputType.COMPLEX).multiple()).build(),
"emp", new VariableNameResolver(), false);
final String initialValue = initializer.getInitialValue();
......
......@@ -25,6 +25,7 @@ import org.bonitasoft.engine.bdm.model.field.Field;
import org.bonitasoft.engine.bdm.model.field.FieldType;
import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.engine.bdm.model.field.SimpleField;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Rule;
import org.junit.Test;
......@@ -50,7 +51,7 @@ public class MultipleBusinessObjectQueryInitializerTest {
aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()
.havingInput(aContractInput()
.withName("persistenceId")).build(),
"myData.employees", false);
"myData.employees", new VariableNameResolver(), false);
initializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(employeeBo, nameField, aContractInput().withName("name")
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()).build()));
......@@ -77,6 +78,6 @@ public class MultipleBusinessObjectQueryInitializerTest {
aContractInput()
.withName("notPersistenceId")
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()).build(),
"myData.employees", false);
"myData.employees", new VariableNameResolver(), false);
}
}
......@@ -21,6 +21,7 @@ import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.
import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Test;
......@@ -34,7 +35,7 @@ public class MultipleCompositionReferencePropertyInitializerTest {
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX))
.build(),
"employee", false);
"employee", new VariableNameResolver(), false);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
......@@ -59,7 +60,7 @@ public class MultipleCompositionReferencePropertyInitializerTest {
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX))
.build(),
"employee", true);
"employee", new VariableNameResolver(), true);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
......@@ -83,7 +84,7 @@ public class MultipleCompositionReferencePropertyInitializerTest {
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple())
.build(),
"employee", false);
"employee", new VariableNameResolver(), false);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
......
......@@ -23,6 +23,7 @@ import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.
import org.bonitasoft.engine.bdm.model.field.FieldType;
import org.bonitasoft.engine.bdm.model.field.SimpleField;
import org.bonitasoft.studio.contract.core.mapping.operation.BusinessObjectInstantiationException;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Rule;
import org.junit.Test;
......@@ -36,7 +37,7 @@ public class NewBusinessObjectInitializerTest {
@Test
public void should_create_groovy_script_as_initial_value() throws Exception {
final NewBusinessObjectInitializer propertyInitializer = new NewBusinessObjectInitializer(aCompositionField(
"address", aBO("org.test.Address").build()), "myAddress", true);
"address", aBO("org.test.Address").build()), "myAddress", new VariableNameResolver(), true);
assertThat(propertyInitializer.getInitialValue()).isEqualTo(
"def addressVar = myAddress == null ? new org.test.Address() : myAddress" + System.lineSeparator() + "return addressVar");
......@@ -46,7 +47,7 @@ public class NewBusinessObjectInitializerTest {
public void should_initialize_new_object_property_for_simple_composed_reference() throws Exception {
final SimpleField streetField = aSimpleField().withName("street").ofType(FieldType.STRING).notNullable().build();
final NewBusinessObjectInitializer propertyInitializer = new NewBusinessObjectInitializer(aCompositionField("address",
aBO("org.test.Address").withField(streetField).build()), "myAddress", true);
aBO("org.test.Address").withField(streetField).build()), "myAddress", new VariableNameResolver(), true);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(null,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX)
......@@ -61,7 +62,8 @@ public class NewBusinessObjectInitializerTest {
@Test
public void should_throw_an_BusinessObjectInstantiationException_when_creating_an_inconsistent_business_object() throws Exception {
final NewBusinessObjectInitializer propertyInitializer = new NewBusinessObjectInitializer(
aCompositionField("address", aBO("org.test.Address").withField(aSimpleField().withName("street").notNullable().build()).build()), "myAddress", true);
aCompositionField("address", aBO("org.test.Address").withField(aSimpleField().withName("street").notNullable().build()).build()), "myAddress",
new VariableNameResolver(), true);
thrown.expect(BusinessObjectInstantiationException.class);
propertyInitializer.getInitialValue();
......
......@@ -24,6 +24,7 @@ import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.field.FieldType;
import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.engine.bdm.model.field.SimpleField;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.junit.Test;
......@@ -37,7 +38,8 @@ public class NewBusinessObjectListInitializerTest {
businessObject);
addressField.setCollection(true);
final AbstractBusinessObjectInitializer propertyInitializer = new NewBusinessObjectListInitializer(addressField, aContractInput().withName("address")
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", false);
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", new VariableNameResolver(),
false);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
......@@ -65,7 +67,8 @@ public class NewBusinessObjectListInitializerTest {
businessObject);
addressField.setCollection(true);
final AbstractBusinessObjectInitializer propertyInitializer = new NewBusinessObjectListInitializer(addressField, aContractInput().withName("address")
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", true);
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", new VariableNameResolver(),
true);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
......@@ -91,7 +94,7 @@ public class NewBusinessObjectListInitializerTest {
businessObject);
addressField.setCollection(true);
final AbstractBusinessObjectInitializer propertyInitializer = new NewBusinessObjectListInitializer(addressField, aContractInput().withName("addresses")
.multiple().build(), "myAddress", false);
.multiple().build(), "myAddress", new VariableNameResolver(), false);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
......
......@@ -30,6 +30,7 @@ import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMapping;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMappingFactory;
import org.bonitasoft.studio.contract.core.mapping.operation.FieldToContractInputMappingBuilder;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.BusinessObjectQueryInitializer;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.IPropertyInitializer;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.MultipleBusinessObjectQueryInitializer;
......@@ -90,7 +91,7 @@ public class BusinessObjectInitializerFactoryTest {
}
private BusinessObjectInitializerFactory newFactory() {
return new BusinessObjectInitializerFactory();
return new BusinessObjectInitializerFactory(new VariableNameResolver());
}
}
......@@ -29,6 +29,7 @@ import org.bonitasoft.engine.bdm.model.BusinessObject;
import org.bonitasoft.engine.bdm.model.field.RelationField;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMapping;
import org.bonitasoft.studio.contract.core.mapping.FieldToContractInputMappingFactory;
import org.bonitasoft.studio.contract.core.mapping.operation.VariableNameResolver;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.AggregationReferencePropertyInitializer;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.CompositionReferencePropertyInitializer;
import org.bonitasoft.studio.contract.core.mapping.operation.initializer.IPropertyInitializer;
......@@ -98,7 +99,7 @@ public class RelationPropertyInitializerFactoryTest {
}
private RelationPropertyInitializerFactory newFactory() {
return new RelationPropertyInitializerFactory();
return new RelationPropertyInitializerFactory(new VariableNameResolver());
}
}
......@@ -15,10 +15,16 @@
package org.bonitasoft.studio.contract.ui.wizard;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.process.builders.BusinessObjectDataBuilder.aBusinessData;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
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.ProcessFactory;
import org.bonitasoft.studio.swt.rules.RealmWithDisplay;
......@@ -26,7 +32,6 @@ import org.eclipse.core.databinding.observable.value.WritableValue;
import org.junit.Rule;
import org.junit.Test;
public class BusinessDataSelectedValidatorTest {
@Rule
......@@ -35,25 +40,46 @@ public class BusinessDataSelectedValidatorTest {
@Test
public void testValidate_OK() throws Exception {
final WritableValue selectedDataObservable = new WritableValue();
selectedDataObservable.setValue(new Object());
final BusinessObjectData businessObjectData = aBusinessData().withClassname("org.test.Employee").build();
selectedDataObservable.setValue(businessObjectData);
final List<Data> availableBusinessData = new ArrayList<Data>();
availableBusinessData.add(ProcessFactory.eINSTANCE.createData());
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable).validate().isOK()).isTrue();
final BusinessObjectModelRepositoryStore businessObjectStore = mock(BusinessObjectModelRepositoryStore.class);
when(businessObjectStore.getBusinessObjectByQualifiedName(businessObjectData.getClassName())).thenReturn(new BusinessObject());
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, businessObjectStore).validate().isOK()).isTrue();
}
@Test
public void testValidate_KO_forEmptyBusinessData() throws Exception {
final WritableValue selectedDataObservable = new WritableValue();
final List<Data> availableBusinessData = new ArrayList<Data>();
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable).validate().isOK()).isFalse();
assertThat(
new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, mock(BusinessObjectModelRepositoryStore.class)).validate()
.isOK()).isFalse();
}
@Test
public void testValidate_KO_forNoBusinessDataSelected() throws Exception {
final WritableValue selectedDataObservable = new WritableValue();
final BusinessObjectData businessObjectData = aBusinessData().withClassname("org.test.Employee").build();
selectedDataObservable.setValue(businessObjectData);
final List<Data> availableBusinessData = new ArrayList<Data>();
availableBusinessData.add(ProcessFactory.eINSTANCE.createData());
final BusinessObjectModelRepositoryStore businessObjectStore = mock(BusinessObjectModelRepositoryStore.class);
when(businessObjectStore.getBusinessObjectByQualifiedName(businessObjectData.getClassName())).thenReturn(null);
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, 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());
assertThat(new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable).validate().isOK()).isFalse();
assertThat(
new BusinessDataSelectedValidator(availableBusinessData, selectedDataObservable, mock(BusinessObjectModelRepositoryStore.class)).validate()
.isOK()).isFalse();
}
}
......@@ -38,13 +38,13 @@ import org.eclipse.text.edits.MalformedTreeException;
public class MappingOperationScriptBuilder {
private static final IFormatterPreferences DEFAULT_FORMATTER_PREFS = new DefaultFormatterPreferences();
private final BusinessObjectInitializerFactory businessObjectInitializerFactory = new BusinessObjectInitializerFactory();
private final PropertyInitializerFactory propertyInitializerFactory = new PropertyInitializerFactory(new RelationPropertyInitializerFactory());
private final BusinessObjectInitializerFactory businessObjectInitializerFactory;
private static final int FORMAT_LEVEL = 0;
private boolean needsDataDependency = false;
private final BusinessObjectData data;
private final FieldToContractInputMapping mapping;
private final Field field;
private final PropertyInitializerFactory propertyInitializerFactory;
public MappingOperationScriptBuilder(final BusinessObjectData data,
final FieldToContractInputMapping mapping,
......@@ -52,6 +52,9 @@ public class MappingOperationScriptBuilder {
this.data = data;
this.mapping = mapping;
this.field = field;
final VariableNameResolver variableNameResolver = new VariableNameResolver();
businessObjectInitializerFactory = new BusinessObjectInitializerFactory(variableNameResolver);
propertyInitializerFactory = new PropertyInitializerFactory(new RelationPropertyInitializerFactory(variableNameResolver));
}
public String toInstanciationScript() throws BusinessObjectInstantiationException {
......
/**
* Copyright (C) 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
* (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.contract.core.mapping.operation;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.HashMap;
import java.util.Map;
import org.bonitasoft.engine.bdm.BDMQueryUtil;
import org.bonitasoft.engine.bdm.model.BusinessObject;