use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testCompleteNullWorkerId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testCompleteNullWorkerId() {
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
LockedExternalTask task = tasks.get(0);
try {
externalTaskService.complete(task.getId(), null);
fail("exception expected");
} catch (ProcessEngineException e) {
assertTextPresent("workerId is null", e.getMessage());
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskSupportTest method testExternalTaskSupport.
@Test
public void testExternalTaskSupport() {
// given
ProcessDefinition processDefinition = rule.getRepositoryService().createProcessDefinitionQuery().singleResult();
// when
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
// then
List<LockedExternalTask> externalTasks = rule.getExternalTaskService().fetchAndLock(1, "aWorker").topic("externalTaskTopic", 5000L).execute();
Assert.assertEquals(1, externalTasks.size());
Assert.assertEquals(processInstance.getId(), externalTasks.get(0).getProcessInstanceId());
// and it is possible to complete the external task successfully and end the process instance
rule.getExternalTaskService().complete(externalTasks.get(0).getId(), "aWorker");
Assert.assertEquals(0L, rule.getRuntimeService().createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MultiTenancyHistoricExternalTaskLogTest method completeExternalTask.
// helper methods
protected void completeExternalTask(String externalTaskId) {
List<LockedExternalTask> list = externalTaskService.fetchAndLock(100, WORKER_ID, true).topic(DEFAULT_TOPIC, LOCK_DURATION).execute();
externalTaskService.complete(externalTaskId, WORKER_ID);
// unlock the remaining tasks
for (LockedExternalTask lockedExternalTask : list) {
if (!lockedExternalTask.getId().equals(externalTaskId)) {
externalTaskService.unlock(lockedExternalTask.getId());
}
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToExternalTask.
public void testPropagateTenantIdToExternalTask() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().serviceTask().camundaType("external").camundaTopic("test").endEvent().done());
startProcessInstance(PROCESS_DEFINITION_KEY);
ExternalTask externalTask = externalTaskService.createExternalTaskQuery().singleResult();
assertThat(externalTask, is(notNullValue()));
// inherit the tenant id from execution
assertThat(externalTask.getTenantId(), is(TENANT_ID));
List<LockedExternalTask> externalTasks = externalTaskService.fetchAndLock(1, "test").topic("test", 1000).execute();
assertThat(externalTasks.size(), is(1));
assertThat(externalTasks.get(0).getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MultiTenancyHistoricExternalTaskLogTest method reportExternalTaskFailure.
protected void reportExternalTaskFailure(String externalTaskId, String topic, String workerId, Integer retries, boolean usePriority, String errorMessage) {
List<LockedExternalTask> list = externalTaskService.fetchAndLock(100, workerId, usePriority).topic(topic, LOCK_DURATION).execute();
externalTaskService.handleFailure(externalTaskId, workerId, errorMessage, ERROR_DETAILS, retries, 0L);
for (LockedExternalTask lockedExternalTask : list) {
externalTaskService.unlock(lockedExternalTask.getId());
}
}
Aggregations