Search in sources :

Example 66 with Incident

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 67 with Incident

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 68 with Incident

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 69 with Incident

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());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 70 with Incident

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Incident (org.camunda.bpm.engine.runtime.Incident)100 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)50 Test (org.junit.Test)50 Deployment (org.camunda.bpm.engine.test.Deployment)40 IncidentQuery (org.camunda.bpm.engine.runtime.IncidentQuery)34 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)19 Job (org.camunda.bpm.engine.runtime.Job)17 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)14 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)13 Execution (org.camunda.bpm.engine.runtime.Execution)10 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)9 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)8 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)4 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 RuntimeService (org.camunda.bpm.engine.RuntimeService)2 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)2