variables.put("counter", new AtomicInteger());
variables.put("nrOfLoops", 2);
ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSequentialActivity", variables);
// first sequential mi execution
Execution miExecution = runtimeService.createExecutionQuery().activityId("miTask").singleResult();
assertNotNull(miExecution);
assertFalse(instance.getId().equals(miExecution.getId()));
assertEquals(0, runtimeService.getVariable(miExecution.getId(), "loopCounter"));
// input mapping
assertEquals(1, runtimeService.createVariableInstanceQuery().variableName("miCounterValue").count());
assertEquals(1, runtimeService.getVariableLocal(miExecution.getId(), "miCounterValue"));
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
// second sequential mi execution
miExecution = runtimeService.createExecutionQuery().activityId("miTask").singleResult();
assertNotNull(miExecution);
assertFalse(instance.getId().equals(miExecution.getId()));
assertEquals(1, runtimeService.getVariable(miExecution.getId(), "loopCounter"));
// input mapping
assertEquals(1, runtimeService.createVariableInstanceQuery().variableName("miCounterValue").count());
assertEquals(2, runtimeService.getVariableLocal(miExecution.getId(), "miCounterValue"));
task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
// variable does not exist outside of scope