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"));
}
}
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());
}
}
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"));
}
}
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"));
}
}
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());
}
}
Aggregations