use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationExternalTaskTest method testContinueProcess.
@Test
public void testContinueProcess() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
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 it is possible to complete the task
LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationExternalTaskTest method testIncident.
@Test
public void testIncident() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS).changeElementId("externalTask", "newExternalTask"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "newExternalTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
ExternalTask externalTask = rule.getExternalTaskService().createExternalTaskQuery().singleResult();
rule.getExternalTaskService().setRetries(externalTask.getId(), 0);
Incident incidentBeforeMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then the incident has migrated
Incident incidentAfterMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
assertNotNull(incidentAfterMigration);
assertEquals(incidentBeforeMigration.getId(), incidentAfterMigration.getId());
assertEquals(Incident.EXTERNAL_TASK_HANDLER_TYPE, incidentAfterMigration.getIncidentType());
assertEquals(externalTask.getId(), incidentAfterMigration.getConfiguration());
assertEquals("newExternalTask", incidentAfterMigration.getActivityId());
assertEquals(targetProcessDefinition.getId(), incidentAfterMigration.getProcessDefinitionId());
assertEquals(externalTask.getExecutionId(), incidentAfterMigration.getExecutionId());
// and it is possible to complete the process
rule.getExternalTaskService().setRetries(externalTask.getId(), 1);
LockedExternalTask task = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
rule.getExternalTaskService().complete(task.getId(), WORKER_ID);
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask 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());
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class HandleExternalTaskAuthorizationTest method testCompleteExternalTask.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testCompleteExternalTask() {
// 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();
testExternalTaskApi(task);
// then
if (authRule.assertScenario(scenario)) {
assertExternalTaskResults();
}
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class GetErrorDetailsAuthorizationTest method testCompleteExternalTask.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testCompleteExternalTask() {
// given
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> tasks = engineRule.getExternalTaskService().fetchAndLock(5, "workerId").topic("externalTaskTopic", 5000L).execute();
LockedExternalTask task = tasks.get(0);
// preconditions method
engineRule.getExternalTaskService().handleFailure(task.getId(), task.getWorkerId(), "anError", ERROR_DETAILS, 1, 1000L);
// when
authRule.init(scenario).withUser("userId").bindResource("processInstanceId", processInstance.getId()).bindResource("processDefinitionKey", "oneExternalTaskProcess").start();
// execution method
currentDetails = engineRule.getExternalTaskService().getExternalTaskErrorDetails(task.getId());
// then
if (authRule.assertScenario(scenario)) {
// assertion method
assertThat(currentDetails, is(ERROR_DETAILS));
}
}
Aggregations