use of org.camunda.bpm.engine.externaltask.LockedExternalTask 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.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteSuspendedTask.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testCompleteSuspendedTask() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask task = externalTasks.get(0);
// when suspending the process instance
runtimeService.suspendProcessInstanceById(processInstance.getId());
// then the external task cannot be completed
try {
externalTaskService.complete(task.getId(), WORKER_ID);
fail("expected exception");
} catch (ProcessEngineException e) {
assertTextPresent("ExternalTask with id '" + task.getId() + "' is suspended", e.getMessage());
}
assertProcessNotEnded(processInstance.getId());
// when activating the process instance again
runtimeService.activateProcessInstanceById(processInstance.getId());
// then the task can be completed
externalTaskService.complete(task.getId(), WORKER_ID);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testSetRetriesResolvesFailureIncident.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetRetriesResolvesFailureIncident() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask lockedTask = externalTasks.get(0);
externalTaskService.handleFailure(lockedTask.getId(), WORKER_ID, "error", 0, LOCK_TIME);
Incident incident = runtimeService.createIncidentQuery().singleResult();
// when
externalTaskService.setRetries(lockedTask.getId(), 5);
// then the incident is resolved
assertEquals(0, runtimeService.createIncidentQuery().count());
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_FULL.getId()) {
HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
assertNotNull(historicIncident);
assertEquals(incident.getId(), historicIncident.getId());
assertTrue(historicIncident.isResolved());
}
// and the task can be fetched again
ClockUtil.setCurrentTime(nowPlus(LOCK_TIME + 3000L));
externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(1, externalTasks.size());
assertEquals(lockedTask.getId(), externalTasks.get(0).getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask 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.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testExtendLockTimeWithDifferentWorkerId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testExtendLockTimeWithDifferentWorkerId() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> lockedTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, 1L).execute();
assertNotNull(lockedTasks);
assertEquals(1, lockedTasks.size());
LockedExternalTask task = lockedTasks.get(0);
// when
try {
externalTaskService.extendLock(task.getId(), "anAnotherWorkerId", 100);
fail("Exception expected");
} catch (BadUserRequestException e) {
assertTrue(e.getMessage().contains("The lock of the External Task " + task.getId() + " cannot be extended by worker 'anAnotherWorkerId'"));
}
}
Aggregations