use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationExternalTaskTest method testLockedTaskContinueProcess.
@Test
public void testLockedTaskContinueProcess() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY).changeElementId("externalTask", "newExternalTask"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("externalTask", "newExternalTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
LockedExternalTask externalTask = fetchAndLockSingleTask(ExternalTaskModels.TOPIC);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then it is possible to complete the task and the process
rule.getExternalTaskService().complete(externalTask.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 testAddParentScope.
@Test
public void testAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ExternalTaskModels.SUBPROCESS_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 MigrationIncidentTest method testExternalTaskIncidentMigration.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess_v2.bpmn" })
public void testExternalTaskIncidentMigration() throws Exception {
// Given we create a new process instance
ProcessDefinition callingProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcess").singleResult();
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(callingProcess.getId());
LockedExternalTask task = engineRule.getExternalTaskService().fetchAndLock(1, "foo").topic("foo", 1000L).execute().get(0);
// creating an incident in the called and calling process
engineRule.getExternalTaskService().handleFailure(task.getId(), "foo", "error", 0, 1000L);
Incident incidentInCallingProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(callingProcess.getId()).singleResult();
// when
ProcessDefinition callingProcessV2 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcessV2").singleResult();
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(callingProcess.getId(), callingProcessV2.getId()).mapEqualActivities().mapActivities("ServiceTask_1p58ywb", "ServiceTask_V2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInCallingProcess.getId()).singleResult();
Assert.assertEquals(callingProcessV2.getId(), incidentAfterMigration.getProcessDefinitionId());
Assert.assertEquals("ServiceTask_V2", incidentAfterMigration.getActivityId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method historicIncidentRemainsOpenAfterMigration.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess_v2.bpmn" })
public void historicIncidentRemainsOpenAfterMigration() {
// Given we create a new process instance
ProcessDefinition process1 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcess").singleResult();
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(process1.getId());
LockedExternalTask task = engineRule.getExternalTaskService().fetchAndLock(1, "foo").topic("foo", 1000L).execute().get(0);
engineRule.getExternalTaskService().handleFailure(task.getId(), "foo", "error", 0, 1000L);
Incident incidentInProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(process1.getId()).singleResult();
// when
ProcessDefinition process2 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcessV2").singleResult();
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(process1.getId(), process2.getId()).mapEqualActivities().mapActivities("ServiceTask_1p58ywb", "ServiceTask_V2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
HistoricIncident historicIncidentAfterMigration = engineRule.getHistoryService().createHistoricIncidentQuery().singleResult();
assertNotNull(historicIncidentAfterMigration);
assertNull(historicIncidentAfterMigration.getEndTime());
assertTrue(historicIncidentAfterMigration.isOpen());
HistoricProcessInstance historicProcessInstanceAfterMigration = engineRule.getHistoryService().createHistoricProcessInstanceQuery().withIncidents().incidentStatus("open").singleResult();
assertNotNull(historicProcessInstanceAfterMigration);
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInProcess.getId()).singleResult();
assertEquals(process2.getId(), incidentAfterMigration.getProcessDefinitionId());
assertEquals("ServiceTask_V2", incidentAfterMigration.getActivityId());
}
use of org.camunda.bpm.engine.externaltask.LockedExternalTask in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method testCallActivityExternalTaskIncidentMigration.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/callingProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/callingProcess_v2.bpmn" })
public void testCallActivityExternalTaskIncidentMigration() throws Exception {
// Given we create a new process instance
ProcessDefinition callingProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("callingProcess").singleResult();
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(callingProcess.getId());
LockedExternalTask task = engineRule.getExternalTaskService().fetchAndLock(1, "foo").topic("foo", 1000L).execute().get(0);
// creating an incident in the called and calling process
engineRule.getExternalTaskService().handleFailure(task.getId(), "foo", "error", 0, 1000L);
Incident incidentInCallingProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(callingProcess.getId()).singleResult();
// when
ProcessDefinition callingProcessV2 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("callingProcessV2").singleResult();
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(callingProcess.getId(), callingProcessV2.getId()).mapEqualActivities().mapActivities("CallActivity", "CallActivityV2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInCallingProcess.getId()).singleResult();
Assert.assertEquals(callingProcessV2.getId(), incidentAfterMigration.getProcessDefinitionId());
Assert.assertEquals("CallActivityV2", incidentAfterMigration.getActivityId());
}
Aggregations