Search in sources :

Example 1 with ExternalTask

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);
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask)

Example 2 with ExternalTask

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;
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 3 with ExternalTask

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());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with ExternalTask

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);
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with ExternalTask

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());
    }
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)108 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)67 Test (org.junit.Test)56 Deployment (org.camunda.bpm.engine.test.Deployment)47 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)24 HistoricExternalTaskLog (org.camunda.bpm.engine.history.HistoricExternalTaskLog)19 Batch (org.camunda.bpm.engine.batch.Batch)16 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)16 ArrayList (java.util.ArrayList)15 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)10 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)8 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)6 Task (org.camunda.bpm.engine.task.Task)6 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)5 HistoricExternalTaskLogQuery (org.camunda.bpm.engine.history.HistoricExternalTaskLogQuery)4 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)4 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 HashMap (java.util.HashMap)2