Search in sources :

Example 51 with LockedExternalTask

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;
}
Also used : LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 52 with LockedExternalTask

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);
}
Also used : ExternalTaskQueryBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 53 with LockedExternalTask

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));
}
Also used : LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Incident(org.camunda.bpm.engine.runtime.Incident)

Example 54 with LockedExternalTask

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 55 with LockedExternalTask

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Aggregations

LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)91 Deployment (org.camunda.bpm.engine.test.Deployment)58 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)33 Test (org.junit.Test)21 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)15 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)9 Incident (org.camunda.bpm.engine.runtime.Incident)8 DateTime (org.joda.time.DateTime)8 Task (org.camunda.bpm.engine.task.Task)7 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)5 FetchExternalTasksExtendedDto (org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto)5 VariableMap (org.camunda.bpm.engine.variable.VariableMap)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ExternalTaskQueryBuilder (org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 InOrder (org.mockito.InOrder)3