use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testUpdateRetriesByAllParameters.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByAllParameters() {
// given
List<String> ids = startProcessInstance("oneExternalTaskProcess", 5);
ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(ids.get(0)).singleResult();
ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery().processInstanceId(ids.get(1));
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(ids.get(2));
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(ids.get(3));
// when
externalTaskService.updateRetries().externalTaskIds(externalTask.getId()).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery).processInstanceIds(ids.get(4)).set(5);
// then
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
assertEquals(5, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(Integer.valueOf(5), task.getRetries());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask 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");
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testSetPriority.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetPriority() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
// when
externalTaskService.setPriority(externalTasks.get(0).getId(), 5);
// then
ExternalTask task = externalTaskService.createExternalTaskQuery().singleResult();
assertEquals(5, (int) task.getPriority());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleBpmnError.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testHandleBpmnError() {
// given
runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
List<LockedExternalTask> externalTasks = helperHandleBpmnError(1, WORKER_ID, TOPIC_NAME, LOCK_TIME, "ERROR-OCCURED");
// then
assertEquals(0, externalTasks.size());
assertEquals(0, externalTaskService.createExternalTaskQuery().count());
Task afterBpmnError = taskService.createTaskQuery().singleResult();
assertNotNull(afterBpmnError);
assertEquals(afterBpmnError.getTaskDefinitionKey(), "afterBpmnError");
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleFailureNullErrorMessage.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testHandleFailureNullErrorMessage() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
// when
externalTaskService.handleFailure(externalTasks.get(0).getId(), WORKER_ID, null, 5, LOCK_TIME);
// then the failure was reported successfully and the error message is null
ExternalTask task = externalTaskService.createExternalTaskQuery().singleResult();
assertEquals(5, (int) task.getRetries());
assertNull(task.getErrorMessage());
assertNull(externalTaskService.getExternalTaskErrorDetails(task.getId()));
}
Aggregations