Search in sources :

Example 31 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldFailForNullExternalTaskIdAsync.

@Test
public void shouldFailForNullExternalTaskIdAsync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    externalTaskIds.add(null);
    Batch batch = null;
    try {
        batch = externalTaskService.setRetriesAsync(externalTaskIds, null, 10);
        executeSeedAndBatchJobs(batch);
        fail("exception expected");
    } catch (BadUserRequestException e) {
        Assert.assertThat(e.getMessage(), containsString("External task id cannot be null"));
    }
}
Also used : 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) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 32 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesSync.

@Test
public void shouldSetExternalTaskRetriesSync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    // when
    externalTaskService.setRetries(externalTaskIds, 10);
    // then
    externalTasks = externalTaskService.createExternalTaskQuery().list();
    for (ExternalTask task : externalTasks) {
        Assert.assertEquals(10, (int) task.getRetries());
    }
}
Also used : ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 33 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldFailForNullExternalTaskIdSync.

@Test
public void shouldFailForNullExternalTaskIdSync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    externalTaskIds.add(null);
    try {
        externalTaskService.setRetries(externalTaskIds, 10);
        fail("exception expected");
    } catch (BadUserRequestException e) {
        Assert.assertThat(e.getMessage(), containsString("External task id cannot be null"));
    }
}
Also used : ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 34 with ExternalTask

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

the class SetExternalTasksRetriesTest method shouldFailForNonExistingExternalTaskIdAsync.

@Test
public void shouldFailForNonExistingExternalTaskIdAsync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    externalTaskIds.add("nonExistingExternalTaskId");
    Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, null, 10);
    try {
        executeSeedAndBatchJobs(batch);
        fail("exception expected");
    } catch (NotFoundException e) {
        Assert.assertThat(e.getMessage(), containsString("Cannot find external task with id nonExistingExternalTaskId"));
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 35 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask 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

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