Commit 2531a8f9 authored by Aurelien Pupier's avatar Aurelien Pupier
Browse files

BS-14264: handle the case of not defined Iterator Expression in order to

have a working 6.x form preview
parent 6945837c
......@@ -22,6 +22,7 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
......@@ -213,6 +214,22 @@ public class EngineFlowElementBuilderTest {
assertThat(argument.getValue().getExpressionType()).isEqualTo(ExpressionType.TYPE_BUSINESS_DATA_REFERENCE.name());
}
@Test
public void testAddIteratorToContext_robustnessWithNullValue() {
final Data collectionDataToMultiInstantiate = BusinessObjectDataBuilder.aBusinessData().withName("bData").withClassname("classname").build();
final TaskBuilder taskB = TaskBuilder.aTask().havingCollectionDataToMultiInstantiate(collectionDataToMultiInstantiate)
.havingData(collectionDataToMultiInstantiate);
final Pool pool = PoolBuilder.aPool().havingElements(taskB).build();
final MainProcess mainProcess = MainProcessBuilder.aMainProcess().build();
mainProcess.getElements().add(pool);
mainProcess.getDatatypes().add(BusinessObjectDataTypeBuilder.aBusinessObjectDataType().withName("classname").build());
flowElementSwitch.addContext(taskBuilder, (Task) pool.getElements().get(0));
verify(taskBuilder, times(0)).addContextEntry(anyString(), any(Expression.class));
}
@Test
public void testAddInputMappingAssignedToData() {
final Pool pool = PoolBuilder.aPool()
......
......@@ -272,17 +272,17 @@ public abstract class AbstractProcessBuilder extends ProcessSwitch<Element> {
protected void addContext(final Object contextBuilder, final Task task) {
final Pool pool = ModelHelper.getParentPool(task);
addContext(contextBuilder, pool);
final org.bonitasoft.studio.model.expression.Expression iteratorExpression = task.getIteratorExpression();
addIteratorToContext(contextBuilder, task, iteratorExpression);
addIteratorToContext(contextBuilder, task);
}
/**
* @param contextBuilder
* @param task
* @param iteratorExpression
*/
protected void addIteratorToContext(final Object contextBuilder, final Task task, final org.bonitasoft.studio.model.expression.Expression iteratorExpression) {
if (ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE.equals(iteratorExpression.getType())
protected void addIteratorToContext(final Object contextBuilder, final Task task) {
final org.bonitasoft.studio.model.expression.Expression iteratorExpression = task.getIteratorExpression();
if (iteratorExpression != null &&
ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE.equals(iteratorExpression.getType())
&& iteratorExpression.getName() != null
&& !iteratorExpression.getName().isEmpty()
&& task instanceof DataAware) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment