use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleBpmnErrorWithoutDefinedBoundary.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testHandleBpmnErrorWithoutDefinedBoundary() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// 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();
assertNull(afterBpmnError);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testFetchSuspendedTask.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testFetchSuspendedTask() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// when suspending the process instance
runtimeService.suspendProcessInstanceById(processInstance.getId());
// then the external task cannot be fetched
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(0, externalTasks.size());
// when activating the process instance
runtimeService.activateProcessInstanceById(processInstance.getId());
// then the task can be fetched
externalTasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
assertEquals(1, externalTasks.size());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteWithLocalVariables.
public void testCompleteWithLocalVariables() {
// given
BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask("externalTask").camundaType("external").camundaTopic("foo").camundaTaskPriority("100").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadLocalVariableListenerImpl.class).userTask("user").endEvent().done();
deployment(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
List<LockedExternalTask> lockedTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic("foo", 1L).execute();
// when
externalTaskService.complete(lockedTasks.get(0).getId(), WORKER_ID, null, Variables.createVariables().putValue("abc", "bar"));
// then
VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstance.getId()).singleResult();
assertNull(variableInstance);
if (processEngineConfiguration.getHistoryLevel() == HistoryLevel.HISTORY_LEVEL_AUDIT || processEngineConfiguration.getHistoryLevel() == HistoryLevel.HISTORY_LEVEL_FULL) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().activityInstanceIdIn(lockedTasks.get(0).getActivityInstanceId()).singleResult();
assertNotNull(historicVariableInstance);
assertEquals("abc", historicVariableInstance.getName());
assertEquals("bar", historicVariableInstance.getValue());
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testHandleBpmnNullErrorCode.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testHandleBpmnNullErrorCode() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// when
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
// then
LockedExternalTask task = tasks.get(0);
try {
externalTaskService.handleBpmnError(task.getId(), WORKER_ID, null);
fail("exception expected");
} catch (ProcessEngineException e) {
assertTextPresent("errorCode is null", e.getMessage());
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testFetchAndLockWithInitialBuilder.
/**
* Note: this does not test a hard API guarantee, i.e. the test is stricter than the API (Javadoc).
* Its purpose is to ensure that the API implementation is less error-prone to use.
*
* Bottom line: if there is good reason to change behavior such that this test breaks, it may
* be ok to change the test.
*/
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testFetchAndLockWithInitialBuilder() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// when
ExternalTaskQueryBuilder initialBuilder = externalTaskService.fetchAndLock(1, WORKER_ID);
initialBuilder.topic(TOPIC_NAME, LOCK_TIME);
// should execute regardless whether the initial builder is used or the builder returned by the
// #topic invocation
List<LockedExternalTask> tasks = initialBuilder.execute();
// then
assertEquals(1, tasks.size());
}
Aggregations