use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testManualStartWithLocalVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testManualStartWithLocalVariables() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
// an enabled child case execution of
// the case instance
String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
// variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("aVariableName", "abc");
variables.put("anotherVariableName", 999);
// when
// activate child case execution
caseService.withCaseExecution(caseExecutionId).setVariablesLocal(variables).manualStart();
// then
// the child case execution is active...
CaseExecution caseExecution = caseExecutionQuery.singleResult();
assertTrue(caseExecution.isActive());
// ... and not enabled
assertFalse(caseExecution.isEnabled());
// there exists a task
Task task = taskService.createTaskQuery().caseExecutionId(caseExecutionId).singleResult();
assertNotNull(task);
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(caseExecutionId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals("abc", variable.getValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(999, variable.getValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceProcessTaskTest method testManualStartWithLocalVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testManualStartWithLocalVariable() {
// given
String caseInstanceId = createCaseInstance(DEFINITION_KEY).getId();
String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK_KEY).getId();
ProcessInstance processInstance = queryProcessInstance();
assertNull(processInstance);
// when
caseService.withCaseExecution(processTaskId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
// then
processInstance = queryProcessInstance();
assertNotNull(processInstance);
assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
assertTrue(processTask.isActive());
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(processTaskId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals("abc", variable.getValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(999, variable.getValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method testManualStartWithLocalVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn" })
public void testManualStartWithLocalVariable() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
// an enabled child case execution of
// the case instance
String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
// when
// activate child case execution
caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
// then
// the child case execution is active...
CaseExecution caseExecution = caseExecutionQuery.singleResult();
assertTrue(caseExecution.isActive());
// ... and not enabled
assertFalse(caseExecution.isEnabled());
// (1) one case case execution representing "PI_HumanTask_1"
verifyTasksState(caseExecutionQuery);
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
verifyVariables(caseInstanceId, caseExecutionId, result);
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceStageTest method testManualWithVariables.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn" })
public void testManualWithVariables() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
// an enabled child case execution of
// the case instance
String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
// variables
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("aVariableName", "abc");
variables.put("anotherVariableName", 999);
// when
// activate child case execution
caseService.withCaseExecution(caseExecutionId).setVariables(variables).manualStart();
// then
// the child case execution is active...
CaseExecution caseExecution = caseExecutionQuery.singleResult();
assertTrue(caseExecution.isActive());
// ... and not enabled
assertFalse(caseExecution.isEnabled());
// (1) one case case execution representing "PI_HumanTask_1"
verifyTasksState(caseExecutionQuery);
// the case instance has two variables:
// - aVariableName
// - anotherVariableName
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
verifyVariables(caseInstanceId, caseInstanceId, result);
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceTest method testExecuteSetVariablesLocalTyped.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testExecuteSetVariablesLocalTyped() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
VariableMap variables = createVariables().putValueTyped("aVariableName", stringValue("abc")).putValueTyped("anotherVariableName", integerValue(null));
// when
caseService.withCaseExecution(caseExecutionId).setVariablesLocal(variables).execute();
// then
// query by caseExecutionId
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().caseExecutionIdIn(caseExecutionId).list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variable : result) {
assertEquals(caseExecutionId, variable.getCaseExecutionId());
assertEquals(caseInstanceId, variable.getCaseInstanceId());
if (variable.getName().equals("aVariableName")) {
assertEquals("aVariableName", variable.getName());
assertEquals(stringValue("abc"), variable.getTypedValue());
} else if (variable.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variable.getName());
assertEquals(integerValue(null), variable.getTypedValue());
} else {
fail("Unexpected variable: " + variable.getName());
}
}
}
Aggregations