use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testUpdateRetriesByProcessInstanceIds.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByProcessInstanceIds() {
// given
List<String> processInstances = startProcessInstance("oneExternalTaskProcess", 5);
// when
externalTaskService.updateRetries().processInstanceIds(processInstances).set(5);
// then
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
assertEquals(5, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleFailureThenComplete.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testHandleFailureThenComplete() {
// given a failed external task with incident
runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask task = tasks.get(0);
externalTaskService.handleFailure(task.getId(), WORKER_ID, "someError", 0, LOCK_TIME);
// when
externalTaskService.complete(task.getId(), WORKER_ID);
// then the task has been completed nonetheless
Task followingTask = taskService.createTaskQuery().singleResult();
assertNotNull(followingTask);
assertEquals("afterExternalTask", followingTask.getTaskDefinitionKey());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask 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.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testUpdateRetriesByProcessInstanceIdArray.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByProcessInstanceIdArray() {
// given
List<String> processInstances = startProcessInstance("oneExternalTaskProcess", 5);
// when
externalTaskService.updateRetries().processInstanceIds(processInstances.toArray(new String[processInstances.size()])).set(5);
// then
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
assertEquals(5, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testUpdateRetriesByHistoricProcessInstanceQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByHistoricProcessInstanceQuery() {
// given
startProcessInstance("oneExternalTaskProcess", 5);
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneExternalTaskProcess");
// when
externalTaskService.updateRetries().historicProcessInstanceQuery(query).set(5);
// then
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
assertEquals(5, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
Aggregations