Search in sources :

Example 36 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldUpdateRetriesByProcessInstanceIds.

@Test
public void shouldUpdateRetriesByProcessInstanceIds() {
    // when
    Batch batch = externalTaskService.updateRetries().processInstanceIds(processInstanceIds).setAsync(5);
    executeSeedAndBatchJobs(batch);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(6, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(5, (int) task.getRetries());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 37 with ExternalTask

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

Example 38 with ExternalTask

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

the class MultiTenancyHistoricExternalTaskLogTest method startProcessInstanceAndFailExternalTask.

@SuppressWarnings("deprecation")
protected ExternalTask startProcessInstanceAndFailExternalTask(String tenant) {
    ProcessInstance pi = runtimeService.createProcessInstanceByKey(DEFAULT_PROCESS_KEY).processDefinitionTenantId(tenant).execute();
    ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(pi.getId()).singleResult();
    reportExternalTaskFailure(externalTask.getId());
    return externalTask;
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 39 with ExternalTask

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

the class ProcessInstanceSuspensionTest method testSuspensionByProcessDefinitionIdCascadesToExternalTasks.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
public void testSuspensionByProcessDefinitionIdCascadesToExternalTasks() {
    // given
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
    ExternalTask task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertFalse(task1.isSuspended());
    // when the process instance is suspended
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processInstance1.getProcessDefinitionId());
    // then the task is suspended
    task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertTrue(task1.isSuspended());
    // the other task is not
    ExternalTask task2 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance2.getId()).singleResult();
    assertFalse(task2.isSuspended());
    // when it is activated again
    runtimeService.activateProcessInstanceByProcessDefinitionId(processInstance1.getProcessDefinitionId());
    // then the task is activated too
    task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertFalse(task1.isSuspended());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 40 with ExternalTask

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

the class ProcessInstanceSuspensionTest method testSuspensionByProcessDefinitionKeyCascadesToExternalTasks.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
public void testSuspensionByProcessDefinitionKeyCascadesToExternalTasks() {
    // given
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
    ExternalTask task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertFalse(task1.isSuspended());
    // when the process instance is suspended
    runtimeService.suspendProcessInstanceByProcessDefinitionKey("oneExternalTaskProcess");
    // then the task is suspended
    task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertTrue(task1.isSuspended());
    // the other task is not
    ExternalTask task2 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance2.getId()).singleResult();
    assertFalse(task2.isSuspended());
    // when it is activated again
    runtimeService.activateProcessInstanceByProcessDefinitionKey("oneExternalTaskProcess");
    // then the task is activated too
    task1 = externalTaskService.createExternalTaskQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertFalse(task1.isSuspended());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

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