Search in sources :

Example 21 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskServiceTest method testUpdateRetriesByProcessInstanceIds.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByProcessInstanceIds() {
    // given
    List<String> processInstances = startProcessInstance("oneExternalTaskProcess", 5);
    // when
    externalTaskService.updateRetries().processInstanceIds(processInstances).set(5);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(5, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(5, (int) task.getRetries());
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 22 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskServiceTest method testHandleFailureThenComplete.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml")
public void testHandleFailureThenComplete() {
    // given a failed external task with incident
    runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
    List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
    LockedExternalTask task = tasks.get(0);
    externalTaskService.handleFailure(task.getId(), WORKER_ID, "someError", 0, LOCK_TIME);
    // when
    externalTaskService.complete(task.getId(), WORKER_ID);
    // then the task has been completed nonetheless
    Task followingTask = taskService.createTaskQuery().singleResult();
    assertNotNull(followingTask);
    assertEquals("afterExternalTask", followingTask.getTaskDefinitionKey());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 23 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskServiceTest method testExternalTaskExecutionTreeExpansion.

@Deployment
public void testExternalTaskExecutionTreeExpansion() {
    // given
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("boundaryExternalTaskProcess");
    List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute();
    LockedExternalTask externalTask = tasks.get(0);
    // when a non-interrupting boundary event is triggered meanwhile
    // such that the execution tree is expanded
    runtimeService.correlateMessage("Message");
    // then the external task can still be completed
    externalTaskService.complete(externalTask.getId(), WORKER_ID);
    ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
    assertThat(activityInstance).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("afterBoundaryTask").done());
    Task afterBoundaryTask = taskService.createTaskQuery().singleResult();
    taskService.complete(afterBoundaryTask.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 24 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskServiceTest method testUpdateRetriesByProcessInstanceIdArray.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByProcessInstanceIdArray() {
    // given
    List<String> processInstances = startProcessInstance("oneExternalTaskProcess", 5);
    // when
    externalTaskService.updateRetries().processInstanceIds(processInstances.toArray(new String[processInstances.size()])).set(5);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(5, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(5, (int) task.getRetries());
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskServiceTest method testUpdateRetriesByHistoricProcessInstanceQuery.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByHistoricProcessInstanceQuery() {
    // given
    startProcessInstance("oneExternalTaskProcess", 5);
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneExternalTaskProcess");
    // when
    externalTaskService.updateRetries().historicProcessInstanceQuery(query).set(5);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(5, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(5, (int) task.getRetries());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)108 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)67 Test (org.junit.Test)56 Deployment (org.camunda.bpm.engine.test.Deployment)47 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)24 HistoricExternalTaskLog (org.camunda.bpm.engine.history.HistoricExternalTaskLog)19 Batch (org.camunda.bpm.engine.batch.Batch)16 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)16 ArrayList (java.util.ArrayList)15 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)10 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)8 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)6 Task (org.camunda.bpm.engine.task.Task)6 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)5 HistoricExternalTaskLogQuery (org.camunda.bpm.engine.history.HistoricExternalTaskLogQuery)4 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)4 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 HashMap (java.util.HashMap)2