use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testSubProcessLocalInputSingleVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivity.testSubProcessLocalInputSingleVariable.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testSubProcessLocalInputSingleVariable() {
ProcessInstance processInstance = startProcessInstanceByKey("subProcessLocalInputSingleVariable");
Task beforeCallActivityTask = taskService.createTaskQuery().singleResult();
// when setting a variable in a process instance
runtimeService.setVariable(processInstance.getId(), "callingProcessVar1", "val1");
// and executing the call activity
taskService.complete(beforeCallActivityTask.getId());
// then the local variable specified in the io mapping is passed to the called instance
CaseExecutionEntity calledInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(calledInstance);
Map<String, Object> calledInstanceVariables = caseService.getVariables(calledInstance.getId());
assertEquals(1, calledInstanceVariables.size());
assertEquals("val2", calledInstanceVariables.get("mappedInputParameter"));
// when setting a variable in the called instance
caseService.setVariable(calledInstance.getId(), "calledCaseVar1", 42L);
// and completing it
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
complete(humanTaskId);
// then the call activity output variable has been mapped to the process instance execution
// and the output mapping variable as well
Map<String, Object> callingInstanceVariables = runtimeService.getVariables(processInstance.getId());
assertEquals(4, callingInstanceVariables.size());
assertEquals("val1", callingInstanceVariables.get("callingProcessVar1"));
assertEquals("val2", callingInstanceVariables.get("mappedInputParameter"));
assertEquals(42L, callingInstanceVariables.get("calledCaseVar1"));
assertEquals(43L, callingInstanceVariables.get("outputParameter"));
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testCallCaseByVersionAsExpression.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseByVersionAsExpression.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseByVersionAsExpression() {
// given
String cmmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn";
String secondDeploymentId = repositoryService.createDeployment().addClasspathResource(cmmnResourceName).deploy().getId();
String thirdDeploymentId = repositoryService.createDeployment().addClasspathResource(cmmnResourceName).deploy().getId();
assertEquals(3, repositoryService.createCaseDefinitionQuery().count());
String caseDefinitionIdInSecondDeployment = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).deploymentId(secondDeploymentId).singleResult().getId();
VariableMap variables = Variables.createVariables().putValue("myVersion", 2);
// when
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, variables).getId();
// then
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertEquals(caseDefinitionIdInSecondDeployment, subCaseInstance.getCaseDefinitionId());
// complete ////////////////////////////////////////////////////////
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
complete(humanTaskId);
close(subCaseInstance.getId());
assertProcessEnded(superProcessInstanceId);
repositoryService.deleteDeployment(secondDeploymentId, true);
repositoryService.deleteDeployment(thirdDeploymentId, true);
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testInputSourceNullValue.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputSource.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputSourceNullValue() {
// given
// when
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
// then
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(subCaseInstance.getId()).list();
assertFalse(variables.isEmpty());
assertEquals(2, variables.size());
for (VariableInstance variable : variables) {
String name = variable.getName();
if ("aVariable".equals(name)) {
assertEquals("aVariable", name);
} else if ("anotherVariable".equals(name)) {
assertEquals("anotherVariable", name);
} else {
fail("Found an unexpected variable: '" + name + "'");
}
assertNull(variable.getValue());
}
// complete ////////////////////////////////////////////////////////
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
complete(humanTaskId);
close(subCaseInstance.getId());
assertProcessEnded(superProcessInstanceId);
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testCallCaseByDeployment.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseByDeployment.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallCaseByDeployment() {
// given
String firstDeploymentId = repositoryService.createDeploymentQuery().singleResult().getId();
String cmmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn";
String deploymentId = repositoryService.createDeployment().addClasspathResource(cmmnResourceName).deploy().getId();
assertEquals(2, repositoryService.createCaseDefinitionQuery().count());
String caseDefinitionIdInSameDeployment = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).deploymentId(firstDeploymentId).singleResult().getId();
// when
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
// then
String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
assertEquals(caseDefinitionIdInSameDeployment, subCaseInstance.getCaseDefinitionId());
// complete ////////////////////////////////////////////////////////
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
complete(humanTaskId);
close(subCaseInstance.getId());
assertProcessEnded(superProcessInstanceId);
repositoryService.deleteDeployment(deploymentId, true);
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testCallLatestCase.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallLatestCase.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCallLatestCase() {
// given
String cmmnResourceName = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn";
String deploymentId = repositoryService.createDeployment().addClasspathResource(cmmnResourceName).deploy().getId();
assertEquals(2, repositoryService.createCaseDefinitionQuery().count());
String latestCaseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).latestVersion().singleResult().getId();
// when
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();
// then
String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
assertEquals(latestCaseDefinitionId, subCaseInstance.getCaseDefinitionId());
// complete ////////////////////////////////////////////////////////
String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();
complete(humanTaskId);
close(subCaseInstance.getId());
assertProcessEnded(superProcessInstanceId);
repositoryService.deleteDeployment(deploymentId, true);
}
Aggregations