use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testScriptExecutionListenerExecutesCommandAfterUserCompletesTask.
@Deployment
public void testScriptExecutionListenerExecutesCommandAfterUserCompletesTask() {
// given
String processInstanceId = startProcessInstanceByKey(DEFAULT_PROCESS_KEY).getId();
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstance variableUser = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId).variableName("userId").singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
assertEquals(2, runtimeService.createProcessInstanceQuery().count());
enableAuthorization();
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testScriptTaskListenerExecutesQueryAfterUserCompletesTask.
@Deployment
public void testScriptTaskListenerExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query.variableName("userId").singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query.variableName("count").singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteWithNonLocalVariables.
public void testCompleteWithNonLocalVariables() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask("externalTask").camundaType("external").camundaTopic("foo").camundaTaskPriority("100").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadLocalVariableListenerImpl.class).userTask("user").endEvent().done();
deployment(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
List<LockedExternalTask> lockedTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic("foo", 1L).execute();
// when
externalTaskService.complete(lockedTasks.get(0).getId(), WORKER_ID, Variables.createVariables().putValue("abc", "bar"), null);
// then
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstance.getId()).singleResult();
assertNotNull(variableInstance);
assertEquals("bar", variableInstance.getValue());
assertEquals("abc", variableInstance.getName());
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class FormServiceTest method testSubmitStartFormWithFormFieldMarkedAsBusinessKey.
@Deployment
@Test
public void testSubmitStartFormWithFormFieldMarkedAsBusinessKey() {
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
ProcessInstance pi = formService.submitStartForm(procDefId, "foo", Variables.createVariables().putValue("secondParam", "bar"));
assertEquals("foo", pi.getBusinessKey());
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertEquals(1, result.size());
assertTrue(result.get(0).getName().equals("secondParam"));
}
use of org.camunda.bpm.engine.runtime.VariableInstance in project camunda-bpm-platform by camunda.
the class CaseServiceHumanTaskTest method testCompleteWithRemoveVariableLocal.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithRemoveVariableLocal() {
// given:
// a deployed case definition
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
// an active case instance
caseService.withCaseDefinition(caseDefinitionId).create();
String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
// when
caseService.withCaseExecution(caseExecutionId).removeVariableLocal("aVariableName").removeVariableLocal("anotherVariableName").complete();
// then
// the task has been completed and has been deleted
task = taskService.createTaskQuery().singleResult();
assertNull(task);
// the corresponding case execution has been also
// deleted and completed
CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
assertNull(caseExecution);
// the case instance is still active
CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
assertNotNull(caseInstance);
assertTrue(caseInstance.isActive());
List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
assertTrue(result.isEmpty());
}
Aggregations