Search in sources :

Example 6 with ExternalTaskQuery

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

the class ExternalTaskServiceTest method testUpdateRetriesByAllParameters.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByAllParameters() {
    // given
    List<String> ids = startProcessInstance("oneExternalTaskProcess", 5);
    ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(ids.get(0)).singleResult();
    ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery().processInstanceId(ids.get(1));
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(ids.get(2));
    HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(ids.get(3));
    // when
    externalTaskService.updateRetries().externalTaskIds(externalTask.getId()).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery).processInstanceIds(ids.get(4)).set(5);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(5, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(Integer.valueOf(5), task.getRetries());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) 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) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 7 with ExternalTaskQuery

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

the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithListAndQueryAsync.

@Test
public void shouldSetExternalTaskRetriesWithListAndQueryAsync() {
    ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery();
    List<ExternalTask> externalTasks = externalTaskQuery.list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    // when
    Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, externalTaskQuery, 5);
    // then
    executeSeedAndBatchJobs(batch);
    externalTasks = externalTaskService.createExternalTaskQuery().list();
    for (ExternalTask task : externalTasks) {
        Assert.assertEquals(5, (int) task.getRetries());
    }
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 8 with ExternalTaskQuery

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

the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithDifferentListAndQueryAsync.

@Test
public void shouldSetExternalTaskRetriesWithDifferentListAndQueryAsync() {
    // given
    ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0));
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(processInstanceIds.size() - 1)).list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    // when
    Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, externalTaskQuery, 8);
    executeSeedAndBatchJobs(batch);
    // then
    ExternalTask task = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
    Assert.assertEquals(8, (int) task.getRetries());
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(processInstanceIds.size() - 1)).list();
    for (ExternalTask t : tasks) {
        Assert.assertEquals(8, (int) t.getRetries());
    }
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 9 with ExternalTaskQuery

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

the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithQueryAsync.

@Test
public void shouldSetExternalTaskRetriesWithQueryAsync() {
    ExternalTaskQuery externalTaskQuery = engineRule.getExternalTaskService().createExternalTaskQuery();
    // when
    Batch batch = externalTaskService.setRetriesAsync(null, externalTaskQuery, 5);
    // then
    executeSeedAndBatchJobs(batch);
    for (ExternalTask task : externalTaskQuery.list()) {
        Assert.assertEquals(5, (int) task.getRetries());
    }
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) 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 10 with ExternalTaskQuery

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

the class SetExternalTasksRetriesTest method shouldUpdateRetriesByAllParameters.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void shouldUpdateRetriesByAllParameters() {
    // given
    ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
    ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(1));
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceIds.get(2));
    HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceIds.get(3));
    // when
    Batch batch = externalTaskService.updateRetries().externalTaskIds(externalTask.getId()).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery).processInstanceIds(processInstanceIds.get(4)).setAsync(5);
    executeSeedAndBatchJobs(batch);
    // then
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
    assertEquals(6, tasks.size());
    for (ExternalTask task : tasks) {
        assertEquals(Integer.valueOf(5), task.getRetries());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) 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) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)35 Test (org.junit.Test)13 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)10 Batch (org.camunda.bpm.engine.batch.Batch)6 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)6 ArrayList (java.util.ArrayList)3 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)3 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)3 ExternalTaskQueryDto (org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto)3 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 HashMap (java.util.HashMap)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ExternalTaskQueryImpl (org.camunda.bpm.engine.impl.ExternalTaskQueryImpl)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1