Search in sources :

Example 61 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class HistoricExternalTaskLogTest method testRetriesAndWorkerIdWhenFirstFailureAndThenComplete.

@Test
public void testRetriesAndWorkerIdWhenFirstFailureAndThenComplete() {
    // given
    ExternalTask task = startExternalTaskProcess();
    reportExternalTaskFailure(task.getId());
    completeExternalTask(task.getId());
    // when
    HistoricExternalTaskLog log = historyService.createHistoricExternalTaskLogQuery().successLog().singleResult();
    // then
    assertEquals(WORKER_ID, log.getWorkerId());
    assertEquals(Integer.valueOf(1), log.getRetries());
    assertLogIsInSuccessfulState(log);
}
Also used : HistoricExternalTaskLog(org.camunda.bpm.engine.history.HistoricExternalTaskLog) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 62 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class HistoricExternalTaskLogTest method testHistoricExternalTaskLogDeletedProperties.

@Test
public void testHistoricExternalTaskLogDeletedProperties() {
    // given
    ExternalTask task = startExternalTaskProcess();
    runtimeService.deleteProcessInstance(task.getProcessInstanceId(), "Dummy reason for deletion!");
    // when
    HistoricExternalTaskLog log = historyService.createHistoricExternalTaskLogQuery().deletionLog().singleResult();
    // then
    assertHistoricLogPropertiesAreProperlySet(task, log);
    assertEquals(null, log.getWorkerId());
    assertLogIsInDeletedState(log);
}
Also used : HistoricExternalTaskLog(org.camunda.bpm.engine.history.HistoricExternalTaskLog) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 63 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class HistoricExternalTaskLogTest method testHistoricExternalTaskLogSuccessfulProperties.

@Test
public void testHistoricExternalTaskLogSuccessfulProperties() {
    // given
    ExternalTask task = startExternalTaskProcess();
    completeExternalTask(task.getId());
    // when
    HistoricExternalTaskLog log = historyService.createHistoricExternalTaskLogQuery().successLog().singleResult();
    // then
    assertHistoricLogPropertiesAreProperlySet(task, log);
    assertEquals(WORKER_ID, log.getWorkerId());
    assertLogIsInSuccessfulState(log);
}
Also used : HistoricExternalTaskLog(org.camunda.bpm.engine.history.HistoricExternalTaskLog) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 64 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceImpl method queryExternalTasks.

@Override
public List<ExternalTaskDto> queryExternalTasks(ExternalTaskQueryDto queryDto, Integer firstResult, Integer maxResults) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    ExternalTaskQuery query = queryDto.toQuery(engine);
    List<ExternalTask> matchingTasks;
    if (firstResult != null || maxResults != null) {
        matchingTasks = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingTasks = query.list();
    }
    List<ExternalTaskDto> taskResults = new ArrayList<ExternalTaskDto>();
    for (ExternalTask task : matchingTasks) {
        ExternalTaskDto resultInstance = ExternalTaskDto.fromExternalTask(task);
        taskResults.add(resultInstance);
    }
    return taskResults;
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) ExternalTaskDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskDto) LockedExternalTaskDto(org.camunda.bpm.engine.rest.dto.externaltask.LockedExternalTaskDto) ArrayList(java.util.ArrayList) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 65 with ExternalTask

use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.

the class MigrationExternalTaskTest method testChangeTaskConfiguration.

@Test
public void testChangeTaskConfiguration() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS).serviceTaskBuilder("externalTask").camundaTopic("new" + ExternalTaskModels.TOPIC).camundaTaskPriority(Integer.toString(ExternalTaskModels.PRIORITY * 2)).done());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "externalTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then the task's topic and priority have not changed
    ExternalTask externalTaskAfterMigration = rule.getExternalTaskService().createExternalTaskQuery().singleResult();
    Assert.assertEquals(ExternalTaskModels.PRIORITY.longValue(), externalTaskAfterMigration.getPriority());
    Assert.assertEquals(ExternalTaskModels.TOPIC, externalTaskAfterMigration.getTopicName());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Test(org.junit.Test)

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