use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createExternalTaskMock.
private void createExternalTaskMock() {
ExternalTaskQuery query = mock(ExternalTaskQuery.class);
List<ExternalTask> tasks = MockProvider.createMockExternalTasks();
when(query.list()).thenReturn(tasks);
when(mockExternalTaskService.createExternalTaskQuery()).thenReturn(query);
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class MockExternalTaskBuilder method buildExternalTask.
public ExternalTask buildExternalTask() {
ExternalTask task = mock(ExternalTask.class);
when(task.getActivityId()).thenReturn(activityId);
when(task.getActivityInstanceId()).thenReturn(activityInstanceId);
when(task.getErrorMessage()).thenReturn(errorMessage);
when(task.getExecutionId()).thenReturn(executionId);
when(task.getId()).thenReturn(id);
when(task.getLockExpirationTime()).thenReturn(lockExpirationTime);
when(task.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(task.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(task.getProcessInstanceId()).thenReturn(processInstanceId);
when(task.getRetries()).thenReturn(retries);
when(task.isSuspended()).thenReturn(suspended);
when(task.getTopicName()).thenReturn(topicName);
when(task.getWorkerId()).thenReturn(workerId);
when(task.getTenantId()).thenReturn(tenantId);
when(task.getPriority()).thenReturn(priority);
return task;
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryByPriorityTest method testFilterByExternalTaskPriorityLowerAndHigher.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerAndHigher() {
// 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 is returned
ExternalTask task = externalTaskService.createExternalTaskQuery().priorityHigherThanOrEquals(2L).priorityLowerThanOrEquals(2L).singleResult();
assertNotNull(task);
assertEquals(2, task.getPriority());
assertEquals(instances.get(2).getId(), task.getProcessInstanceId());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryByPriorityTest method testFilterByExternalTaskPriorityLowerThanOrEquals.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerThanOrEquals() {
// given five jobs with priorities from 1 to 5
// each process has two external tasks - one with priority expression and one without priority
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 priority
// then the correct external tasks are returned
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().priorityLowerThanOrEquals(2).list();
assertEquals(8, tasks.size());
for (ExternalTask task : tasks) {
assertTrue(task.getPriority() <= 2);
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByActivityId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/parallelExternalTaskProcess.bpmn20.xml")
public void testQueryByActivityId() {
// given
startInstancesByKey("parallelExternalTaskProcess", 3);
// when
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().activityId("externalTask2").list();
// then
assertEquals(3, tasks.size());
for (ExternalTask task : tasks) {
assertEquals("externalTask2", task.getActivityId());
}
}
Aggregations