use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByProcessInstanceId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByProcessInstanceId() {
// given
List<ProcessInstance> processInstances = startInstancesByKey("oneExternalTaskProcess", 3);
// when
ExternalTask task = externalTaskService.createExternalTaskQuery().processInstanceId(processInstances.get(0).getId()).singleResult();
// then
assertNotNull(task);
assertEquals(processInstances.get(0).getId(), task.getProcessInstanceId());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByProcessInstanceIdIn.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByProcessInstanceIdIn() {
// given
List<ProcessInstance> processInstances = startInstancesByKey("oneExternalTaskProcess", 3);
List<String> processInstanceIds = Arrays.asList(processInstances.get(0).getId(), processInstances.get(1).getId());
// when
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().processInstanceIdIn(processInstances.get(0).getId(), processInstances.get(1).getId()).list();
// then
assertNotNull(tasks);
assertEquals(2, tasks.size());
for (ExternalTask task : tasks) {
assertTrue(processInstanceIds.contains(task.getProcessInstanceId()));
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByWorkerId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByWorkerId() {
// given
startInstancesByKey("oneExternalTaskProcess", 10);
lockInstances(TOPIC_NAME, 10000L, 3, "worker1");
lockInstances(TOPIC_NAME, 10000L, 4, "worker2");
// when
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().workerId("worker1").list();
// then
assertEquals(3, tasks.size());
for (ExternalTask task : tasks) {
assertEquals("worker1", task.getWorkerId());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testSingleResult.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSingleResult() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
// when
ExternalTask externalTask = externalTaskService.createExternalTaskQuery().singleResult();
// then
assertNotNull(externalTask.getId());
assertEquals(processInstance.getId(), externalTask.getProcessInstanceId());
assertEquals("externalTask", externalTask.getActivityId());
assertNotNull(externalTask.getActivityInstanceId());
assertNotNull(externalTask.getExecutionId());
assertEquals(processInstance.getProcessDefinitionId(), externalTask.getProcessDefinitionId());
assertEquals("oneExternalTaskProcess", externalTask.getProcessDefinitionKey());
assertEquals(TOPIC_NAME, externalTask.getTopicName());
assertNull(externalTask.getWorkerId());
assertNull(externalTask.getLockExpirationTime());
assertFalse(externalTask.isSuspended());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByLockState.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByLockState() {
// given
startInstancesByKey("oneExternalTaskProcess", 5);
lockInstances(TOPIC_NAME, 10000L, 3, WORKER_ID);
// when
List<ExternalTask> lockedTasks = externalTaskService.createExternalTaskQuery().locked().list();
List<ExternalTask> nonLockedTasks = externalTaskService.createExternalTaskQuery().notLocked().list();
// then
assertEquals(3, lockedTasks.size());
for (ExternalTask task : lockedTasks) {
assertNotNull(task.getLockExpirationTime());
}
assertEquals(2, nonLockedTasks.size());
for (ExternalTask task : nonLockedTasks) {
assertNull(task.getLockExpirationTime());
}
}
Aggregations