Search in sources :

Example 71 with ExternalTask

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

the class CompleteProcessWithExternalTaskTest method testCompleteProcessWithFetchedExternalTask.

@Test
@ScenarioUnderTest("init.fetch.1")
public void testCompleteProcessWithFetchedExternalTask() throws InterruptedException {
    // given process with locked external task
    String buisnessKey = rule.getBuisnessKey();
    ExternalTask task = rule.getExternalTaskService().createExternalTaskQuery().locked().topicName(buisnessKey).workerId(buisnessKey).singleResult();
    Assert.assertNotNull(task);
    // when external task is completed
    rule.getExternalTaskService().complete(task.getId(), buisnessKey);
    // then no locked external task with worker id exists
    task = rule.getExternalTaskService().createExternalTaskQuery().locked().topicName(buisnessKey).workerId(buisnessKey).singleResult();
    assertNull(task);
    rule.assertScenarioEnded();
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 72 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldUpdateRetriesByExternalTaskIds.

@Test
public void shouldUpdateRetriesByExternalTaskIds() {
    // given
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    List<String> externalTaskIds = Arrays.asList(tasks.get(0).getId(), tasks.get(1).getId(), tasks.get(2).getId(), tasks.get(3).getId(), tasks.get(4).getId(), tasks.get(5).getId());
    // when
    Batch batch = externalTaskService.updateRetries().externalTaskIds(externalTaskIds).setAsync(5);
    executeSeedAndBatchJobs(batch);
    // then
    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) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 73 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldUpdateRetriesByExternalTaskIdArray.

@Test
public void shouldUpdateRetriesByExternalTaskIdArray() {
    // given
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    List<String> externalTaskIds = Arrays.asList(tasks.get(0).getId(), tasks.get(1).getId(), tasks.get(2).getId(), tasks.get(3).getId(), tasks.get(4).getId(), tasks.get(5).getId());
    // when
    Batch batch = externalTaskService.updateRetries().externalTaskIds(externalTaskIds.toArray(new String[externalTaskIds.size()])).setAsync(5);
    executeSeedAndBatchJobs(batch);
    // then
    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) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 74 with ExternalTask

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

the class ExternalTaskQueryByPriorityTest method testFilterByExternalTaskPriorityHigherThanOrEquals.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityHigherThanOrEquals() {
    // given five jobs with priorities from 1 to 5
    List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
    for (int i = 0; i < 5; i++) {
        instances.add(runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess", Variables.createVariables().putValue("priority", i)));
    }
    // when making a external task query and filtering by external task priority
    // then the correct external task are returned
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().priorityHigherThanOrEquals(2L).list();
    assertEquals(3, tasks.size());
    Set<String> processInstanceIds = new HashSet<String>();
    processInstanceIds.add(instances.get(2).getId());
    processInstanceIds.add(instances.get(3).getId());
    processInstanceIds.add(instances.get(4).getId());
    for (ExternalTask task : tasks) {
        assertTrue(task.getPriority() >= 2);
        assertTrue(processInstanceIds.contains(task.getProcessInstanceId()));
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) HashSet(java.util.HashSet) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 75 with ExternalTask

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

the class ExternalTaskQueryTest method testQueryBySuspensionState.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryBySuspensionState() {
    // given
    startInstancesByKey("oneExternalTaskProcess", 5);
    suspendInstances(3);
    // when
    List<ExternalTask> suspendedTasks = externalTaskService.createExternalTaskQuery().suspended().list();
    List<ExternalTask> activeTasks = externalTaskService.createExternalTaskQuery().active().list();
    // then
    assertEquals(3, suspendedTasks.size());
    for (ExternalTask task : suspendedTasks) {
        assertTrue(task.isSuspended());
    }
    assertEquals(2, activeTasks.size());
    for (ExternalTask task : activeTasks) {
        assertFalse(task.isSuspended());
        assertFalse(suspendedTasks.contains(task));
    }
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) 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