Search in sources :

Example 46 with ExternalTask

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

the class HistoricExternalTaskLogAuthorizationTest method completeExternalTaskWithFailure.

protected void completeExternalTaskWithFailure(ProcessInstance pi) {
    ExternalTask task = externalTaskService.createExternalTaskQuery().processInstanceId(pi.getId()).singleResult();
    completeExternalTaskWithFailure(task.getId());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 47 with ExternalTask

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

the class HandleExternalTaskFailureAuthorizationTest method assertExternalTaskResults.

@Override
public void assertExternalTaskResults() {
    ExternalTask externalTask = engineRule.getExternalTaskService().createExternalTaskQuery().singleResult();
    Assert.assertEquals(5, (int) externalTask.getRetries());
    Assert.assertEquals("error", externalTask.getErrorMessage());
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 48 with ExternalTask

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

the class SetExternalTasksRetriesAuthorizationTest method testSetRetrieSync.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetRetrieSync() {
    // given
    ProcessInstance processInstance1 = engineRule.getRuntimeService().startProcessInstanceByKey("oneExternalTaskProcess");
    ProcessInstance processInstance2 = engineRule.getRuntimeService().startProcessInstanceByKey("oneExternalTaskProcess");
    List<ExternalTask> tasks = engineRule.getExternalTaskService().createExternalTaskQuery().list();
    // when
    authRule.init(scenario).withUser("userId").bindResource("processInstanceId1", processInstance1.getId()).bindResource("processInstanceId2", processInstance2.getId()).bindResource("processDefinitionKey", "oneExternalTaskProcess").start();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    externalTaskIds.add(tasks.get(0).getId());
    externalTaskIds.add(tasks.get(1).getId());
    engineRule.getExternalTaskService().setRetries(externalTaskIds, 5);
    // then
    if (authRule.assertScenario(scenario)) {
        tasks = engineRule.getExternalTaskService().createExternalTaskQuery().list();
        Assert.assertEquals(5, (int) tasks.get(0).getRetries());
        Assert.assertEquals(5, (int) tasks.get(1).getRetries());
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with ExternalTask

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

the class SetExternalTasksRetriesBatchAuthorizationTest method testSetRetriesWithQueryAsync.

@Test
public void testSetRetriesWithQueryAsync() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
    ProcessInstance processInstance1 = engineRule.getRuntimeService().startProcessInstanceByKey("Process");
    List<ExternalTask> externalTasks;
    ExternalTaskQuery externalTaskQuery = engineRule.getExternalTaskService().createExternalTaskQuery();
    // when
    authRule.init(scenario).withUser("userId").bindResource("batchId", "*").bindResource("processInstance1", processInstance1.getId()).bindResource("processDefinition", processDefinition.getKey()).start();
    Batch batch = engineRule.getExternalTaskService().setRetriesAsync(null, externalTaskQuery, 5);
    if (batch != null) {
        executeSeedAndBatchJobs(batch);
    }
    // then
    if (authRule.assertScenario(scenario)) {
        externalTasks = engineRule.getExternalTaskService().createExternalTaskQuery().list();
        for (ExternalTask task : externalTasks) {
            Assert.assertEquals(5, (int) task.getRetries());
        }
    }
}
Also used : ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Example 50 with ExternalTask

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

the class UnlockExternalTaskAuthorizationTest method testSetJobPriority.

@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testSetJobPriority() {
    // given
    ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("oneExternalTaskProcess");
    List<LockedExternalTask> tasks = engineRule.getExternalTaskService().fetchAndLock(5, "workerId").topic("externalTaskTopic", 5000L).execute();
    LockedExternalTask task = tasks.get(0);
    // when
    authRule.init(scenario).withUser("userId").bindResource("processInstanceId", processInstance.getId()).bindResource("processDefinitionKey", "oneExternalTaskProcess").start();
    engineRule.getExternalTaskService().unlock(task.getId());
    // then
    if (authRule.assertScenario(scenario)) {
        ExternalTask externalTask = engineRule.getExternalTaskService().createExternalTaskQuery().singleResult();
        Assert.assertNull(externalTask.getLockExpirationTime());
    }
}
Also used : LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) 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) 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