use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testOutputVariablesShouldNotExistAnymore.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testOutputAll.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testOutputVariablesShouldNotExistAnymore() {
// given
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
VariableMap parameters = Variables.createVariables().putValue("aVariable", "xyz").putValue("anotherVariable", 123);
runtimeService.setVariablesLocal(callActivityId, parameters);
String subCaseInstanceId = queryOneTaskCaseInstance().getId();
caseService.withCaseExecution(subCaseInstanceId).setVariable("aVariable", "abc").setVariable("anotherVariable", 999).execute();
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
// when
complete(humanTaskId);
// then
// the variables has been deleted
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().processInstanceIdIn(superProcessInstanceId).list();
assertTrue(variables.isEmpty());
// complete ////////////////////////////////////////////////////////
close(subCaseInstanceId);
assertCaseEnded(subCaseInstanceId);
String taskId = queryTaskByActivityId(USER_TASK_ID).getId();
taskService.complete(taskId);
assertProcessEnded(superProcessInstanceId);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class ModifyVariableInSameTransactionTest method testInsertDeleteInsertTheSameVariable.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testInsertDeleteInsertTheSameVariable() {
BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("serviceTaskProcess").startEvent().userTask("userTask").serviceTask("service").camundaClass(InsertDeleteInsertVariableDelegate.class).userTask("userTask1").endEvent().done();
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(bpmnModel);
VariableMap variables = Variables.createVariables().putValue("listVar", Arrays.asList(new int[] { 1, 2, 3 }));
ProcessInstance instance = engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(), variables);
Task task = engineRule.getTaskService().createTaskQuery().singleResult();
engineRule.getTaskService().complete(task.getId());
VariableInstance variable = engineRule.getRuntimeService().createVariableInstanceQuery().processInstanceIdIn(instance.getId()).variableName("foo").singleResult();
assertNotNull(variable);
assertEquals("bar", variable.getValue());
List<HistoricVariableInstance> historyVariables = engineRule.getHistoryService().createHistoricVariableInstanceQuery().list();
for (HistoricVariableInstance historicVariable : historyVariables) {
if (variable.getName().equals(historicVariable.getName())) {
assertEquals(HistoricVariableInstance.STATE_CREATED, historicVariable.getState());
break;
}
}
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TargetVariableScopeTest method testExecutionWithoutProperTargetScope.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/variables/scope/TargetVariableScopeTest.testExecutionWithoutProperTargetScope.bpmn", "org/camunda/bpm/engine/test/api/variables/scope/doer.bpmn" })
public void testExecutionWithoutProperTargetScope() {
VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 }));
// fails due to inappropriate variable scope target
thrown.expect(ScriptEvaluationException.class);
ProcessDefinition processDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("Process_MultiInstanceCallAcitivity").singleResult();
thrown.expectMessage(startsWith("Unable to evaluate script while executing activity 'CallActivity_1' in the process definition with id '" + processDefinition.getId() + "': org.camunda.bpm.engine.ProcessEngineException: ENGINE-20011 Scope with specified activity Id NOT_EXISTING and execution"));
engineRule.getRuntimeService().startProcessInstanceByKey("Process_MultiInstanceCallAcitivity", variables);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class TargetVariableScopeTest method testWithDelegateVariableMappingAndChildScope.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/variables/scope/doer.bpmn" })
public void testWithDelegateVariableMappingAndChildScope() {
BpmnModelInstance instance = Bpmn.createExecutableProcess("process1").startEvent().parallelGateway().subProcess("SubProcess_1").embeddedSubProcess().startEvent().callActivity().calledElement("Process_StuffDoer").camundaVariableMappingClass("org.camunda.bpm.engine.test.api.variables.scope.SetVariableToChildMappingDelegate").serviceTask().camundaClass("org.camunda.bpm.engine.test.api.variables.scope.AssertVariableScopeDelegate").endEvent().subProcessDone().moveToLastGateway().subProcess("SubProcess_2").embeddedSubProcess().startEvent().userTask("ut").endEvent().subProcessDone().endEvent().done();
instance = modify(instance).activityBuilder("SubProcess_1").multiInstance().parallel().camundaCollection("orderIds").camundaElementVariable("orderId").done();
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(instance);
thrown.expect(ProcessEngineException.class);
thrown.expectMessage(startsWith("org.camunda.bpm.engine.ProcessEngineException: ENGINE-20011 Scope with specified activity Id SubProcess_2 and execution"));
VariableMap variables = Variables.createVariables().putValue("orderIds", Arrays.asList(new int[] { 1, 2, 3 }));
engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(), variables);
}
use of org.camunda.bpm.engine.variable.VariableMap in project camunda-bpm-platform by camunda.
the class BoundaryErrorEventTest method testCatchExceptionThrownByExecuteOfDelegateExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml" })
public void testCatchExceptionThrownByExecuteOfDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
variables.putAll(throwException());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
Aggregations