use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByExecutionId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByExecutionId() {
// given
List<ProcessInstance> processInstances = startInstancesByKey("oneExternalTaskProcess", 3);
ProcessInstance firstInstance = processInstances.get(0);
ActivityInstance externalTaskActivityInstance = runtimeService.getActivityInstance(firstInstance.getId()).getActivityInstances("externalTask")[0];
String executionId = externalTaskActivityInstance.getExecutionIds()[0];
// when
ExternalTask externalTask = externalTaskService.createExternalTaskQuery().executionId(executionId).singleResult();
// then
assertNotNull(externalTask);
assertEquals(executionId, externalTask.getExecutionId());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByProcessDefinitionId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByProcessDefinitionId() {
// given
org.camunda.bpm.engine.repository.Deployment secondDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml").deploy();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
startInstancesById(processDefinitions.get(0).getId(), 3);
startInstancesById(processDefinitions.get(1).getId(), 2);
// when
List<ExternalTask> definition1Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions.get(0).getId()).list();
List<ExternalTask> definition2Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions.get(1).getId()).list();
// then
assertEquals(3, definition1Tasks.size());
for (ExternalTask task : definition1Tasks) {
assertEquals(processDefinitions.get(0).getId(), task.getProcessDefinitionId());
}
assertEquals(2, definition2Tasks.size());
for (ExternalTask task : definition2Tasks) {
assertEquals(processDefinitions.get(1).getId(), task.getProcessDefinitionId());
}
// cleanup
repositoryService.deleteDeployment(secondDeployment.getId(), true);
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByActivityIdIn.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/parallelExternalTaskProcess.bpmn20.xml")
public void testQueryByActivityIdIn() {
// given
startInstancesByKey("parallelExternalTaskProcess", 3);
List<String> activityIds = Arrays.asList("externalTask1", "externalTask2");
// when
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().activityIdIn((String[]) activityIds.toArray()).list();
// then
assertEquals(6, tasks.size());
for (ExternalTask task : tasks) {
assertTrue(activityIds.contains(task.getActivityId()));
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByLargeListOfProcessInstanceIdIn.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByLargeListOfProcessInstanceIdIn() {
// given
List<String> processInstances = new ArrayList<String>();
for (int i = 0; i < 1001; i++) {
processInstances.add(runtimeService.startProcessInstanceByKey("oneExternalTaskProcess").getProcessInstanceId());
}
// when
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().processInstanceIdIn(processInstances.toArray(new String[processInstances.size()])).list();
// then
assertNotNull(tasks);
assertEquals(1001, tasks.size());
for (ExternalTask task : tasks) {
assertTrue(processInstances.contains(task.getProcessInstanceId()));
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testUpdateRetriesByExternalTaskQuery.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testUpdateRetriesByExternalTaskQuery() {
// given
startProcessInstance("oneExternalTaskProcess", 5);
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
// when
externalTaskService.updateRetries().externalTaskQuery(query).set(5);
// then
List<ExternalTask> tasks = query.list();
assertEquals(5, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
Aggregations