use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MockExternalTaskBuilder method buildLockedExternalTask.
public LockedExternalTask buildLockedExternalTask() {
LockedExternalTask task = mock(LockedExternalTask.class);
when(task.getActivityId()).thenReturn(activityId);
when(task.getActivityInstanceId()).thenReturn(activityInstanceId);
when(task.getErrorMessage()).thenReturn(errorMessage);
when(task.getExecutionId()).thenReturn(executionId);
when(task.getId()).thenReturn(id);
when(task.getLockExpirationTime()).thenReturn(lockExpirationTime);
when(task.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(task.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(task.getProcessInstanceId()).thenReturn(processInstanceId);
when(task.getRetries()).thenReturn(retries);
when(task.getTopicName()).thenReturn(topicName);
when(task.getWorkerId()).thenReturn(workerId);
when(task.getTenantId()).thenReturn(tenantId);
when(task.getVariables()).thenReturn(variables);
when(task.getPriority()).thenReturn(priority);
return task;
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceImpl method fetchAndLock.
@Override
public List<LockedExternalTaskDto> fetchAndLock(FetchExternalTasksDto fetchingDto) {
ExternalTaskQueryBuilder fetchBuilder = fetchingDto.buildQuery(processEngine);
List<LockedExternalTask> externalTasks = fetchBuilder.execute();
return LockedExternalTaskDto.fromLockedExternalTasks(externalTasks);
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToFailedExternalTaskIncident.
public void testPropagateTenantIdToFailedExternalTaskIncident() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().serviceTask().camundaType("external").camundaTopic("test").endEvent().done());
startProcessInstance(PROCESS_DEFINITION_KEY);
// fetch the external task and mark it as failed which create an incident
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, "test-worker").topic("test", 1000).execute();
externalTaskService.handleFailure(tasks.get(0).getId(), "test-worker", "expected", 0, 0);
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertThat(incident, is(notNullValue()));
// inherit the tenant id from execution
assertThat(incident.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationExternalTaskTest method testRemoveParentScope.
@Test
public void testRemoveParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then it is possible to complete the task
LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationExternalTaskTest method testChangeTaskType.
@Test
public void testChangeTaskType() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.newModel().startEvent().businessRuleTask("externalBusinessRuleTask").camundaType(ExternalTaskModels.EXTERNAL_TASK_TYPE).camundaTopic(ExternalTaskModels.TOPIC).camundaTaskPriority(ExternalTaskModels.PRIORITY.toString()).endEvent().done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalBusinessRuleTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then the task and process can be completed
LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
testHelper.assertProcessEnded(processInstance.getId());
}
Aggregations