use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseTaskTest method testCallCaseByDeployment.
/**
* default behaviour of manual activation changed - remove manual activation
*/
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testCallCaseByDeployment.cmmn", "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(3, repositoryService.createCaseDefinitionQuery().count());
String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
String caseDefinitionIdInSameDeployment = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(ONE_TASK_CASE).deploymentId(firstDeploymentId).singleResult().getId();
// then
CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(subCaseInstance);
String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);
assertEquals(caseTaskId, superCaseExecutionId);
assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
assertEquals(caseDefinitionIdInSameDeployment, subCaseInstance.getCaseDefinitionId());
// complete ////////////////////////////////////////////////////////
terminate(subCaseInstance.getId());
close(subCaseInstance.getId());
assertCaseEnded(subCaseInstance.getId());
terminate(caseTaskId);
close(superCaseInstanceId);
assertCaseEnded(superCaseInstanceId);
repositoryService.deleteDeployment(deploymentId, true);
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CreateCaseInstanceCmd method execute.
public CaseInstance execute(CommandContext commandContext) {
ensureAtLeastOneNotNull("caseDefinitionId and caseDefinitionKey are null", caseDefinitionId, caseDefinitionKey);
CaseDefinitionEntity caseDefinition = find(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateCaseInstance(caseDefinition);
}
// Start the case instance
CaseExecutionEntity caseInstance = (CaseExecutionEntity) caseDefinition.createCaseInstance(businessKey);
caseInstance.create(variables);
return caseInstance;
}
use of org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity in project camunda-bpm-platform by camunda.
the class CaseCallActivityTest method testInputAll.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputAll.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testInputAll() {
// given
VariableMap parameters = Variables.createVariables().putValue("aVariable", "abc").putValue("anotherVariable", 999);
// when
String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, parameters).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);
assertEquals("abc", variable.getValue());
} else if ("anotherVariable".equals(name)) {
assertEquals("anotherVariable", name);
assertEquals(999, variable.getValue());
} else {
fail("Found an unexpected variable: '" + name + "'");
}
}
// 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 testSubProcessLocalOutputSingleVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivity.testSubProcessLocalOutputSingleVariable.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testSubProcessLocalOutputSingleVariable() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessLocalOutputSingleVariable");
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 all variables have been mapped into the called instance
CaseExecutionEntity calledInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
assertNotNull(calledInstance);
Map<String, Object> calledInstanceVariables = caseService.getVariables(calledInstance.getId());
assertEquals(2, calledInstanceVariables.size());
assertEquals("val1", calledInstanceVariables.get("callingProcessVar1"));
assertEquals("val2", calledInstanceVariables.get("inputParameter"));
// 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 only the output mapping variable has been mapped into the calling process instance
Map<String, Object> callingInstanceVariables = runtimeService.getVariables(processInstance.getId());
assertEquals(2, callingInstanceVariables.size());
assertEquals("val1", callingInstanceVariables.get("callingProcessVar1"));
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 testSubProcessLocalInputAllVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivity.testSubProcessLocalInputAllVariables.bpmn20.xml", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testSubProcessLocalInputAllVariables() {
ProcessInstance processInstance = startProcessInstanceByKey("subProcessLocalInputAllVariables");
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 only 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("inputParameter"));
// 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(3, callingInstanceVariables.size());
assertEquals("val1", callingInstanceVariables.get("callingProcessVar1"));
assertEquals(42L, callingInstanceVariables.get("calledCaseVar1"));
assertEquals(43L, callingInstanceVariables.get("outputParameter"));
}
Aggregations