Commit d8e0243b authored by Bonita CI's avatar Bonita CI
Browse files

Merge branch 'CP_7.1.0_Sprint_7' into 'master'

parents 0a645fe7 4474a826
......@@ -69,9 +69,10 @@ public abstract class FinishAndAddCustomWizardDialog extends CustomWizardDialog
protected void buttonPressed(final int buttonId) {
super.buttonPressed(buttonId);
if (buttonId == CREATE_AND_NEW_ID) {
getWizard().performFinish();
close();
actionOnFinishAndAdd();
if (getWizard().performFinish()) {
close();
actionOnFinishAndAdd();
}
}
}
......
......@@ -58,17 +58,18 @@ atLeastOneAttributeShouldBeSelectedError=At least one attribute should be checke
attributeName = Attribute name
warningAddFromData_noDataAvailable=Please create first a business variable from Data view.
warningAddFromData_noDataSelected=Please select a business variable in the list.
reminderForStepMessage=Contract elements and mapping operations will be generated and can be edited manually. Storage operations to update business variables can also be generated.\nSelect the option that suits your needs:
reminderForStepMessage=Contract elements and mapping operations will be generated and can be edited manually.\nStorage operations to update business variables can also be generated.\nSelect the option that suits your needs:
reminderForProcessMessage=Contract elements will be generated and can be edited manually.\nThe groovy script to initialize business variables can also be generated.\nSelect the option that best suits your needs:
contractInputDescriptionTooltip=Used in the automatically generated forms as user hint
errorTitle=Error
contractFromDataCreationErrorMessage=An error occurred while generating the contract from a data.
contractGenerationTitle=Contract generation
contractGenerationMsg=Generated contract elements and operations can be edited manually.\nHowever, in many cases, no refactoring is performed (e.g.: Updating name or multiple attribute in a Business object or contract element may break a generated operation).
contractOperationGenerationMsg=The contract inputs have been specified.\n\nOperations to set the values of the business variable attributes with the contract inputs values will be generated.They can be viewed in the Operations pane.\nIf operations have already been generated for these attributes, they will not be replaced. The new operations are added to the list.\n\nContract inputs and operations 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 operation).
doNotShowMeAgain=Do not show me this dialog again
notAllAttributesGeneratedTitle=incomplete initialization of the business variable
notAllAttributesGeneratedMsg=Some attributes of the business variable will not be initialized from the contract elements as they have been deselected.
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.
\ No newline at end of file
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
......@@ -60,6 +60,17 @@ public class FieldToContractInputMappingFactoryTest {
assertThat(mappings).extracting("field.name").containsOnly("manager");
}
@Test
public void should_create_fieldMappingToContractInputMapping_from_complex_business_object_recursive_with_aggregation_field() {
final BusinessObject businessObject = aBO("Employee")
.withField(RelationFieldBuilder.anAggregationField("manager", aBO("Employee").build())).build();
final FieldToContractInputMappingFactory factory = new FieldToContractInputMappingFactory();
final List<FieldToContractInputMapping> mappings = factory.createMappingForBusinessObjectType(businessObject);
assertThat(mappings).extracting("field.name").containsOnly("manager");
}
@Test
public void should_create_fieldMappingToContractInputMapping_from_complex_business_object_with_composition_field() {
final BusinessObject businessObject = aBO("Employee")
......@@ -91,6 +102,18 @@ public class FieldToContractInputMappingFactoryTest {
.isEmpty()).isTrue();
}
@Test
public void should_create_fieldMappingToContractInputMappingTree_withADepth_of_five_when_business_model_is_recursive_with_agregation() {
final BusinessObject businessObject = aBO("Employee").build();
businessObject.addField(RelationFieldBuilder.anAggregationField("employee", businessObject));
final FieldToContractInputMappingFactory factory = new FieldToContractInputMappingFactory();
final List<FieldToContractInputMapping> mappings = factory.createMappingForBusinessObjectType(businessObject);
final FieldToContractInputMapping lastMappingChild = mappings.get(0).getChildren().get(1).getChildren().get(1).getChildren().get(1).getChildren().get(1).getChildren().get(1);
assertThat(lastMappingChild.getChildren().size()).isEqualTo(1);
}
@Test
public void should_create_a_persistenceId_mapping_for_aggregated_field() {
final BusinessObject businessObject = aBO("Employee").build();
......@@ -104,4 +127,5 @@ public class FieldToContractInputMappingFactoryTest {
assertThat(((RelationFieldToContractInputMapping) mappings.get(0)).getChildren()).extracting("field.name").contains("persistenceId");
}
}
......@@ -169,7 +169,7 @@ public class RootContractInputGeneratorTest {
rootContractInputGenerator.build(businessObjectData);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor.forClass(FieldToContractInputMapping.class);
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture());
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture(), eq(false));
final FieldToContractInputMapping fieldToContractInputMapping = argumentCaptor.getValue();
assertThat(fieldToContractInputMapping.getField().getName()).isEqualTo("rootInputName");
assertThat(fieldToContractInputMapping.getField().isCollection()).isFalse();
......@@ -192,7 +192,7 @@ public class RootContractInputGeneratorTest {
rootContractInputGenerator.build(businessObjectData);
final ArgumentCaptor<FieldToContractInputMapping> argumentCaptor = ArgumentCaptor.forClass(FieldToContractInputMapping.class);
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture());
verify(expressionBuilder).toExpression(eq(businessObjectData), argumentCaptor.capture(), eq(false));
final FieldToContractInputMapping fieldToContractInputMapping = argumentCaptor.getValue();
assertThat(fieldToContractInputMapping.getField().getName()).isEqualTo("rootInputName");
assertThat(fieldToContractInputMapping.getField().isCollection()).isTrue();
......
......@@ -29,6 +29,7 @@ import org.bonitasoft.engine.bdm.model.field.SimpleField;
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.operation.BusinessObjectInstantiationException;
import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.assertions.ExpressionAssert;
......@@ -36,6 +37,7 @@ import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.assertions.ContractInputAssert;
import org.eclipse.jdt.core.JavaModelException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
......@@ -59,7 +61,7 @@ public class FieldToContractInputMappingExpressionBuilderTest {
mapping.toContractInput(aContractInput().withName("employee").withType(ContractInputType.COMPLEX).build());
final BusinessObjectData businessObjectData = aBusinessData().withName("myEmployee").build();
final Expression expression = expressionBuilder.toExpression(businessObjectData,
mapping);
mapping, false);
ExpressionAssert.assertThat(expression)
.hasName("employee.address")
......@@ -77,7 +79,7 @@ public class FieldToContractInputMappingExpressionBuilderTest {
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
final FieldToContractInputMapping mapping = aSimpleMapping(lastNameField).build();
final Expression expression = expressionBuilder.toExpression(aBusinessData().withName("myEmployee").build(),
mapping);
mapping, false);
ExpressionAssert.assertThat(expression)
.hasName("lastName")
......@@ -98,7 +100,7 @@ public class FieldToContractInputMappingExpressionBuilderTest {
final BusinessObjectData data = aBusinessData().withName("myEmployee").build();
final Expression expression = expressionBuilder.toExpression(data,
mapping);
mapping, false);
ExpressionAssert.assertThat(expression)
.hasName("employee.lastName")
......@@ -109,4 +111,24 @@ public class FieldToContractInputMappingExpressionBuilderTest {
ContractInputAssert.assertThat((ContractInput) expression.getReferencedElements().get(0)).hasName("employee");
}
@Test
public void should_not_add_businessVariable_dependency_forInitializationScript() throws JavaModelException, BusinessObjectInstantiationException {
final FieldToContractInputMappingExpressionBuilder expressionBuilder = new FieldToContractInputMappingExpressionBuilder(repositoryAccessor,
expressionEditorService);
final RelationField address = aCompositionField("address", aBO("Address").build());
final FieldToContractInputMapping mapping = aRelationMapping(address).build();
mapping.toContractInput(aContractInput().withName("employee").withType(ContractInputType.COMPLEX).build());
final BusinessObjectData businessObjectData = aBusinessData().withName("myEmployee").build();
final Expression expression = expressionBuilder.toExpression(businessObjectData,
mapping, true);
ExpressionAssert.assertThat(expression)
.hasName("employee.address")
.hasContent("def addressVar = myEmployee.address == null ? new Address() : myEmployee.address" + System.lineSeparator() + "return addressVar")
.hasReturnType("Address")
.hasType(ExpressionConstants.SCRIPT_TYPE);
assertThat(expression.getReferencedElements()).hasSize(1);
}
}
......@@ -24,6 +24,7 @@ import static org.bonitasoft.studio.model.expression.builders.ExpressionBuilder.
import static org.bonitasoft.studio.model.process.builders.BusinessObjectDataBuilder.aBusinessData;
import static org.bonitasoft.studio.model.process.builders.ContractInputBuilder.aContractInput;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
......@@ -81,7 +82,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
final SimpleField lastNameField = aSimpleField().withName("lastName").ofType(FieldType.STRING).build();
final FieldToContractInputMapping mapping = aSimpleMapping(lastNameField).build();
final BusinessObjectData data = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(data, mapping)).thenReturn(anExpression().build());
when(expressionBuilder.toExpression(data, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(data,
mapping);
......@@ -95,7 +96,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
.hasType(ExpressionConstants.VARIABLE_TYPE);
assertThat(operation.getLeftOperand().getReferencedElements()).hasSize(1);
verify(expressionBuilder).toExpression(data, mapping);
verify(expressionBuilder).toExpression(data, mapping, false);
}
@Test
......@@ -108,7 +109,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
.withName("employee").build());
final BusinessObjectData data = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(data, mapping)).thenReturn(anExpression().build());
when(expressionBuilder.toExpression(data, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(data,
mapping);
......@@ -121,7 +122,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
.hasName("myEmployee").hasContent("myEmployee")
.hasType(ExpressionConstants.VARIABLE_TYPE);
assertThat(operation.getLeftOperand().getReferencedElements()).hasSize(1);
verify(expressionBuilder).toExpression(data, mapping);
verify(expressionBuilder).toExpression(data, mapping, false);
}
@Test
......@@ -132,7 +133,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
final FieldToContractInputMapping mapping = aRelationMapping(address).build();
mapping.toContractInput(aContractInput().withName("employee").withType(ContractInputType.COMPLEX).build());
final BusinessObjectData businessObjectData = aBusinessData().withName("myEmployee").build();
when(expressionBuilder.toExpression(businessObjectData, mapping)).thenReturn(anExpression().build());
when(expressionBuilder.toExpression(businessObjectData, mapping, false)).thenReturn(anExpression().build());
final Operation operation = inputToOperation.toOperation(businessObjectData,
mapping);
......@@ -145,7 +146,7 @@ public class FieldToContractInputMappingOperationBuilderTest {
.hasType(ExpressionConstants.VARIABLE_TYPE);
assertThat(operation.getLeftOperand().getReferencedElements()).hasSize(1);
verify(expressionBuilder).toExpression(businessObjectData, mapping);
verify(expressionBuilder).toExpression(businessObjectData, mapping, false);
}
@Test
......@@ -153,7 +154,8 @@ 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))).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());
......@@ -170,7 +172,8 @@ 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))).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);
......@@ -182,7 +185,8 @@ 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))).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);
......
......@@ -44,7 +44,7 @@ public class MultipleAggregationReferencePropertyInitializerTest {
final MultipleAggregationReferencePropertyInitializer initializer = new MultipleAggregationReferencePropertyInitializer(null, employeeBo,
employeesField, aContractInput().withName("persistenceId")
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(), "emp");
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", false);
final String initialValue = initializer.getInitialValue();
......@@ -63,6 +63,37 @@ public class MultipleAggregationReferencePropertyInitializerTest {
+ "return employeeList}()");
}
@Test
public void should_embbed_aggregation_list_in_a_closure_WithoutExistingOnAPool() throws Exception {
final BusinessObject employeeBo = aBO("Employee").build();
final SimpleField pIdField = new SimpleField();
pIdField.setName(Field.PERSISTENCE_ID);
pIdField.setType(FieldType.LONG);
employeeBo.addField(pIdField);
final SimpleField nameField = aStringField("name").build();
employeeBo.addField(nameField);
final RelationField employeesField = anAggregationField("employees", employeeBo);
employeesField.setCollection(true);
final MultipleAggregationReferencePropertyInitializer initializer = new MultipleAggregationReferencePropertyInitializer(null, employeeBo,
employeesField, aContractInput().withName("persistenceId")
.in(aContractInput().withName("employees").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", true);
final String initialValue = initializer.getInitialValue();
assertThat(initialValue).isEqualTo("{" + System.lineSeparator()
+ "def employeeList = []" + System.lineSeparator()
+ "//For each item collected in multiple input" + System.lineSeparator()
+ "employees.each{" + System.lineSeparator()
+ "//Add aggregated Employee instance" + System.lineSeparator()
+ "employeeList.add({ currentEmployeeInput ->" + System.lineSeparator()
+ "def employeeVar = employeeDAO.findByPersistenceId(currentEmployeeInput.persistenceId.toLong())" + System.lineSeparator()
+ "return employeeVar" + System.lineSeparator()
+ "}(it))" + System.lineSeparator()
+ "}" + System.lineSeparator()
+ "return employeeList}()");
}
@Test
public void should_use_parent_as_iterator() throws Exception {
final BusinessObject directoryBo = aBO("Directory").build();
......@@ -81,7 +112,7 @@ 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");
.in(aContractInput().withName("direcotries").withType(ContractInputType.COMPLEX).multiple()).build(), "emp", false);
final String initialValue = initializer.getInitialValue();
......
......@@ -50,7 +50,7 @@ public class MultipleBusinessObjectQueryInitializerTest {
aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()
.havingInput(aContractInput()
.withName("persistenceId")).build(),
"myData.employees");
"myData.employees", false);
initializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(employeeBo, nameField, aContractInput().withName("name")
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()).build()));
......@@ -77,6 +77,6 @@ public class MultipleBusinessObjectQueryInitializerTest {
aContractInput()
.withName("notPersistenceId")
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple()).build(),
"myData.employees");
"myData.employees", false);
}
}
......@@ -34,7 +34,7 @@ public class MultipleCompositionReferencePropertyInitializerTest {
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX))
.build(),
"employee");
"employee", false);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
......@@ -51,6 +51,29 @@ public class MultipleCompositionReferencePropertyInitializerTest {
+ "return addressList}()");
}
@Test
public void should_build_a_closure_for_multiple_field_in_a_single_businessObject_without_existingValueOnPool() throws Exception {
final RelationField field = aCompositionField("addresses", aBO("Address").build());
field.setCollection(true);
final MultipleCompositionReferencePropertyInitializer initializer = new MultipleCompositionReferencePropertyInitializer(null, field,
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX))
.build(),
"employee", true);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
+ "//For each item collected in multiple input" + System.lineSeparator()
+ "employeeInput.addresses.each{" + System.lineSeparator()
+ "//Add a new composed Address instance" + System.lineSeparator()
+ "addressList.add({ currentAddressInput ->" + System.lineSeparator()
+ "def addressVar = new Address()" + System.lineSeparator()
+ "return addressVar" + System.lineSeparator()
+ "}(it))" + System.lineSeparator()
+ "}" + System.lineSeparator()
+ "return addressList}()");
}
@Test
public void should_build_a_closure_using_parent_iterator_for_multiple_field_in_a_multiple_businessObject() throws Exception {
final RelationField field = aCompositionField("addresses", aBO("Address").build());
......@@ -60,7 +83,7 @@ public class MultipleCompositionReferencePropertyInitializerTest {
aContractInput().withName("addresses").multiple()
.in(aContractInput().withName("employeeInput").withType(ContractInputType.COMPLEX).multiple())
.build(),
"employee");
"employee", false);
assertThat(initializer.getInitialValue()).isEqualTo("{" + System.lineSeparator()
+ "def addressList = []" + System.lineSeparator()
......
......@@ -37,7 +37,7 @@ 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");
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", false);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
......@@ -57,6 +57,32 @@ public class NewBusinessObjectListInitializerTest {
+ "return addressList");
}
@Test
public void should_initialize_new_object_property_for_multiple_composed_reference_withoutExistingOnPool() throws Exception {
final SimpleField streetField = aSimpleField().withName("street").ofType(FieldType.STRING).notNullable().build();
final BusinessObject businessObject = aBO("org.test.Address").withField(streetField).build();
final RelationField addressField = aCompositionField("address",
businessObject);
addressField.setCollection(true);
final AbstractBusinessObjectInitializer propertyInitializer = new NewBusinessObjectListInitializer(addressField, aContractInput().withName("address")
.multiple().in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX)).build(), "myAddresses", true);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
.in(aContractInput().withName("employee").withType(ContractInputType.COMPLEX))).build()));
assertThat(propertyInitializer.getInitialValue()).isEqualTo("def addressList = []" + System.lineSeparator()
+ "//For each item collected in multiple input" + System.lineSeparator()
+ "employee.address.each{" + System.lineSeparator()
+ "//Add a new composed Address instance" + System.lineSeparator()
+ "addressList.add({ currentAddressInput ->" + System.lineSeparator()
+ "def addressVar = new org.test.Address()" + System.lineSeparator()
+ "addressVar.street = currentAddressInput.street" + System.lineSeparator()
+ "return addressVar" + System.lineSeparator()
+ "}(it))" + System.lineSeparator()
+ "}" + System.lineSeparator()
+ "return addressList");
}
@Test
public void should_not_add_existing_object_to_list_input_is_a_root_input() throws Exception {
final SimpleField streetField = aSimpleField().withName("street").ofType(FieldType.STRING).notNullable().build();
......@@ -65,7 +91,7 @@ public class NewBusinessObjectListInitializerTest {
businessObject);
addressField.setCollection(true);
final AbstractBusinessObjectInitializer propertyInitializer = new NewBusinessObjectListInitializer(addressField, aContractInput().withName("addresses")
.multiple().build(), "myAddress");
.multiple().build(), "myAddress", false);
propertyInitializer.addPropertyInitializer(new SimpleFieldPropertyInitializer(businessObject,
streetField, aContractInput().withName("street")
.in(aContractInput().withName("address").withType(ContractInputType.COMPLEX).multiple()
......
......@@ -46,7 +46,7 @@ public class BusinessObjectInitializerFactoryTest {
final RelationField aCompositionField = aCompositionField("employee", aBO("Employee").build());
final FieldToContractInputMapping mapping = aRelationMapping(aCompositionField)
.addChild(aSimpleMapping(aStringField("name").build())).build();
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping, aBusinessData().withName("employee").build());
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping, aBusinessData().withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(NewBusinessObjectInitializer.class);
}
......@@ -60,7 +60,7 @@ public class BusinessObjectInitializerFactoryTest {
final FieldToContractInputMapping mapping = FieldToContractInputMappingBuilder
.aRelationMapping(aCompositionField)
.addChild(aSimpleMapping(aStringField("name").build())).build();
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping, aBusinessData().withName("employee").build());
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping, aBusinessData().withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(NewBusinessObjectListInitializer.class);
}
......@@ -71,7 +71,7 @@ public class BusinessObjectInitializerFactoryTest {
final BusinessObject businessObject = aBO("Employee").withField(anAggregationField("country", aBO("Country").build())).build();
final List<FieldToContractInputMapping> mappings = new FieldToContractInputMappingFactory().createMappingForBusinessObjectType(businessObject);
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mappings.get(0), aBusinessData().withName("employee").build());
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mappings.get(0), aBusinessData().withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(BusinessObjectQueryInitializer.class);
}
......@@ -84,7 +84,7 @@ public class BusinessObjectInitializerFactoryTest {
final BusinessObject businessObject = aBO("Employee").withField(anAggregationField).build();
final List<FieldToContractInputMapping> mappings = new FieldToContractInputMappingFactory().createMappingForBusinessObjectType(businessObject);
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mappings.get(0), aBusinessData()
.withName("employee").build());
.withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(MultipleBusinessObjectQueryInitializer.class);
}
......
......@@ -51,7 +51,7 @@ public class PropertyInitializerFactoryTest {
final PropertyInitializerFactory factory = newFactory();
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(aSimpleMapping(aStringField("name").build()).build(), aBusinessData()
.withName("employee").build());
.withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(SimpleFieldPropertyInitializer.class);
}
......@@ -66,7 +66,7 @@ public class PropertyInitializerFactoryTest {
.aRelationMapping(employee)
.addChild(aSimpleMapping(aStringField("name").build())).build();
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping.getChildren().get(0), aBusinessData()
.withName("employee").build());
.withName("employee").build(), false);
assertThat(propertyInitializer).isInstanceOf(SimpleFieldPropertyInitializer.class);
assertThat(((SimpleFieldPropertyInitializer) propertyInitializer).getParentBusinessObject()).isNotNull();
......@@ -82,9 +82,9 @@ public class PropertyInitializerFactoryTest {
.addChild(aRelationMapping(employee)).build();
final BusinessObjectData businessObjectData = aBusinessData()
.withName("employee").build();
factory.newPropertyInitializer(mapping.getChildren().get(0), businessObjectData);
factory.newPropertyInitializer(mapping.getChildren().get(0), businessObjectData, false);
verify(relationFactory).newPropertyInitializer(mapping.getChildren().get(0), businessObjectData);
verify(relationFactory).newPropertyInitializer(mapping.getChildren().get(0), businessObjectData, false);
}
@Test
......@@ -93,7 +93,7 @@ public class PropertyInitializerFactoryTest {
thrown.expect(UnsupportedOperationException.class);
factory.newPropertyInitializer(new FakeMapping(new Field() {
}), aBusinessData().build());
}), aBusinessData().build(), false);
}
private PropertyInitializerFactory newFactory() {
......
......@@ -49,7 +49,7 @@ public class RelationPropertyInitializerFactoryTest {
.addChild(aRelationMapping(addressField))
.addChild(aSimpleMapping(aStringField("street").build())).build();
final IPropertyInitializer propertyInitializer = factory.newPropertyInitializer(mapping.getChildren().get(0), aBusinessData()