use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessApplicationElResolverTest method testCallActivityOutputExpression.
/**
* Tests that an expression for a call activity output parameter is resolved
* in the context of the called process definition's application.
*/
public void testCallActivityOutputExpression() {
// given an instance of the calling process that calls the called process
ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess");
// when the called process is completed
Task calledProcessTask = taskService.createTaskQuery().singleResult();
taskService.complete(calledProcessTask.getId());
// then the output mapping should have successfully resolved the expression
String outVariable = (String) runtimeService.getVariable(instance.getId(), "outVar");
assertEquals(CalledProcessApplication.STRING_VARIABLE_VALUE, outVariable);
}
use of org.camunda.bpm.engine.task.Task 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.task.Task in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithMultiInstanceBody.
@Deployment
public void testExecutionListenerWithMultiInstanceBody() {
final AtomicInteger eventCountForMultiInstanceBody = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if ("miTasks#multiInstanceBody".equals(execution.getCurrentActivityId()) && (ExecutionListener.EVENTNAME_START.equals(execution.getEventName()) || ExecutionListener.EVENTNAME_END.equals(execution.getEventName()))) {
eventCountForMultiInstanceBody.incrementAndGet();
}
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// complete task
List<Task> miTasks = taskService.createTaskQuery().list();
for (Task task : miTasks) {
taskService.complete(task.getId());
}
// 2 events are expected: one for mi body start; one for mi body end
assertEquals(2, eventCountForMultiInstanceBody.get());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testExecutionListenerWithTimerBoundaryEvent.
@Deployment
public void testExecutionListenerWithTimerBoundaryEvent() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
eventCount.incrementAndGet();
}
};
}
};
// register app so that it is notified about events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// 1. (start)startEvent(end) -(take)-> (start)userTask(end) -(take)-> (start)endEvent(end) (8 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// complete task
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertEquals(10, eventCount.get());
// reset counter
eventCount.set(0);
// 2. (start)startEvent(end) -(take)-> (start)userTask(end)/(start)timerBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
// start process instance
runtimeService.startProcessInstanceByKey("executionListener");
// fire timer event
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
assertEquals(12, eventCount.get());
}
use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleBpmnErrorLockExpiredTask.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testHandleBpmnErrorLockExpiredTask() {
// given
runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
// and the lock expires without the task being reclaimed
ClockUtil.setCurrentTime(new DateTime(ClockUtil.getCurrentTime()).plus(LOCK_TIME * 2).toDate());
externalTaskService.handleBpmnError(externalTasks.get(0).getId(), WORKER_ID, "ERROR-OCCURED");
externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(0, externalTasks.size());
assertEquals(0, externalTaskService.createExternalTaskQuery().count());
Task afterBpmnError = taskService.createTaskQuery().singleResult();
assertNotNull(afterBpmnError);
assertEquals(afterBpmnError.getTaskDefinitionKey(), "afterBpmnError");
}
Aggregations