use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method testJobIncidentMigration.
@Test
public void testJobIncidentMigration() {
// Given we deploy process definitions
testHelper.deploy(FAIL_CALLED_PROC, NEW_CALLED_PROC);
ProcessDefinition failingProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(FAIL_CALLED_PROC_KEY).singleResult();
ProcessDefinition newProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(NEW_CALLED_PROC_KEY).singleResult();
// create process instance and execute job which fails
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey(FAIL_CALLED_PROC_KEY);
testHelper.executeAvailableJobs();
Incident incidentInCallingProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(failingProcess.getId()).singleResult();
// when
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(failingProcess.getId(), newProcess.getId()).mapEqualActivities().mapActivities("task", "taskV2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInCallingProcess.getId()).singleResult();
Assert.assertEquals(newProcess.getId(), incidentAfterMigration.getProcessDefinitionId());
Assert.assertEquals("taskV2", incidentAfterMigration.getActivityId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method testCallActivityJobIncidentMigration.
@Test
public void testCallActivityJobIncidentMigration() {
// Given we deploy process definitions
testHelper.deploy(FAIL_CALLED_PROC, FAIL_CALL_ACT_JOB_PROC, NEW_CALLED_PROC, NEW_CALL_ACT_PROC);
ProcessDefinition failingProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(FAIL_CALL_PROC_KEY).singleResult();
ProcessDefinition newProcess = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(NEW_CALL_PROC_KEY).singleResult();
// create process instance and execute job which fails
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey(FAIL_CALL_PROC_KEY);
testHelper.executeAvailableJobs();
Incident incidentInCallingProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(failingProcess.getId()).singleResult();
// when
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(failingProcess.getId(), newProcess.getId()).mapEqualActivities().mapActivities("calling", "callingV2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInCallingProcess.getId()).singleResult();
Assert.assertEquals(newProcess.getId(), incidentAfterMigration.getProcessDefinitionId());
Assert.assertEquals("callingV2", incidentAfterMigration.getActivityId());
}
use of org.camunda.bpm.engine.runtime.Incident 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.runtime.Incident 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.runtime.Incident 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