use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testExternalTaskExecutionTreeExpansion.
@Deployment
public void testExternalTaskExecutionTreeExpansion() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryExternalTaskProcess");
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask externalTask = tasks.get(0);
// when a non-interrupting boundary event is triggered meanwhile
// such that the execution tree is expanded
runtimeService.correlateMessage("Message");
// then the external task can still be completed
externalTaskService.complete(externalTask.getId(), WORKER_ID);
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterBoundaryTask").done());
Task afterBoundaryTask = taskService.createTaskQuery().singleResult();
taskService.complete(afterBoundaryTask.getId());
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testFetchWithEmptyListOfVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testFetchWithEmptyListOfVariables() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// when
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic("externalTaskTopic", LOCK_TIME).variables(new String[] {}).execute();
// then
assertEquals(1, tasks.size());
LockedExternalTask task = tasks.get(0);
assertNotNull(task.getId());
assertEquals(0, task.getVariables().size());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testSetRetriesToZero.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetRetriesToZero() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask lockedTask = externalTasks.get(0);
// when
externalTaskService.setRetries(lockedTask.getId(), 0);
// then
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertEquals(lockedTask.getId(), incident.getConfiguration());
// and resetting the retries removes the incident again
externalTaskService.setRetries(lockedTask.getId(), 5);
assertEquals(0, runtimeService.createIncidentQuery().count());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testAfterSetPriorityFetchHigherTask.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskWithPriorityProcess.bpmn20.xml")
public void testAfterSetPriorityFetchHigherTask() {
// given
runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess");
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(2, WORKER_ID, true).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(2, externalTasks.size());
LockedExternalTask task = externalTasks.get(1);
assertEquals(0, task.getPriority());
externalTaskService.setPriority(task.getId(), 9);
// and the lock expires without the task being reclaimed
ClockUtil.setCurrentTime(new DateTime(ClockUtil.getCurrentTime()).plus(LOCK_TIME * 2).toDate());
// then
externalTasks = externalTaskService.fetchAndLock(1, "anotherWorkerId", true).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(externalTasks.get(0).getPriority(), 9);
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteWithVariables.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testCompleteWithVariables() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
externalTaskService.complete(externalTasks.get(0).getId(), WORKER_ID, Variables.createVariables().putValue("var", 42));
// then
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterExternalTask").done());
assertEquals(42, runtimeService.getVariable(processInstance.getId(), "var"));
}
Aggregations