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