use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateIncidentOnFailedStartTimerEvent.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateIncidentOnFailedStartTimerEvent.bpmn" })
public void testShouldCreateIncidentOnFailedStartTimerEvent() {
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
Job job = jobQuery.singleResult();
String jobId = job.getId();
while (0 != job.getRetries()) {
try {
managementService.executeJob(jobId);
fail();
} catch (Exception e) {
// expected
}
job = jobQuery.jobId(jobId).singleResult();
}
// job exists
job = jobQuery.singleResult();
assertNotNull(job);
assertEquals(0, job.getRetries());
// incident was created
Incident incident = runtimeService.createIncidentQuery().configuration(job.getId()).singleResult();
assertNotNull(incident);
// manually delete job for timer start event
managementService.deleteJob(job.getId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateOneIncidentForNestedExecution.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncidentForNestedExecution.bpmn" })
public void testShouldCreateOneIncidentForNestedExecution() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcessWithNestedExecutions");
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(incident);
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
String executionIdOfNestedFailingExecution = job.getExecutionId();
assertFalse(processInstance.getId() == executionIdOfNestedFailingExecution);
assertNotNull(incident.getId());
assertNotNull(incident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType());
assertEquals(AlwaysFailingDelegate.MESSAGE, incident.getIncidentMessage());
assertEquals(executionIdOfNestedFailingExecution, incident.getExecutionId());
assertEquals("theServiceTask", incident.getActivityId());
assertEquals(processInstance.getId(), incident.getProcessInstanceId());
assertEquals(incident.getId(), incident.getCauseIncidentId());
assertEquals(incident.getId(), incident.getRootCauseIncidentId());
assertEquals(job.getId(), incident.getConfiguration());
assertEquals(job.getJobDefinitionId(), incident.getJobDefinitionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateRecursiveIncidentsForNestedCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateRecursiveIncidentsForNestedCallActivity.bpmn", "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateRecursiveIncidents.bpmn", "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn" })
public void testShouldCreateRecursiveIncidentsForNestedCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callingFailingCallActivity");
executeAvailableJobs();
List<Incident> incidents = runtimeService.createIncidentQuery().list();
assertFalse(incidents.isEmpty());
assertTrue(incidents.size() == 3);
// Root Cause Incident
ProcessInstance failingProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("failingProcess").singleResult();
assertNotNull(failingProcess);
Incident rootCauseIncident = runtimeService.createIncidentQuery().processDefinitionId(failingProcess.getProcessDefinitionId()).singleResult();
assertNotNull(rootCauseIncident);
Job job = managementService.createJobQuery().executionId(rootCauseIncident.getExecutionId()).singleResult();
assertNotNull(job);
assertNotNull(rootCauseIncident.getId());
assertNotNull(rootCauseIncident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, rootCauseIncident.getIncidentType());
assertEquals(AlwaysFailingDelegate.MESSAGE, rootCauseIncident.getIncidentMessage());
assertEquals(job.getExecutionId(), rootCauseIncident.getExecutionId());
assertEquals("theServiceTask", rootCauseIncident.getActivityId());
assertEquals(failingProcess.getId(), rootCauseIncident.getProcessInstanceId());
assertEquals(rootCauseIncident.getId(), rootCauseIncident.getCauseIncidentId());
assertEquals(rootCauseIncident.getId(), rootCauseIncident.getRootCauseIncidentId());
assertEquals(job.getId(), rootCauseIncident.getConfiguration());
assertEquals(job.getJobDefinitionId(), rootCauseIncident.getJobDefinitionId());
// Cause Incident
ProcessInstance callFailingProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("callFailingProcess").singleResult();
assertNotNull(callFailingProcess);
Incident causeIncident = runtimeService.createIncidentQuery().processDefinitionId(callFailingProcess.getProcessDefinitionId()).singleResult();
assertNotNull(causeIncident);
Execution theCallActivityExecution = runtimeService.createExecutionQuery().activityId("theCallActivity").singleResult();
assertNotNull(theCallActivityExecution);
assertNotNull(causeIncident.getId());
assertNotNull(causeIncident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, causeIncident.getIncidentType());
assertNull(causeIncident.getIncidentMessage());
assertEquals(theCallActivityExecution.getId(), causeIncident.getExecutionId());
assertEquals("theCallActivity", causeIncident.getActivityId());
assertEquals(callFailingProcess.getId(), causeIncident.getProcessInstanceId());
assertEquals(rootCauseIncident.getId(), causeIncident.getCauseIncidentId());
assertEquals(rootCauseIncident.getId(), causeIncident.getRootCauseIncidentId());
assertNull(causeIncident.getConfiguration());
assertNull(causeIncident.getJobDefinitionId());
// Top level incident of the startet process (recursive created incident for super super process instance)
Incident topLevelIncident = runtimeService.createIncidentQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertNotNull(topLevelIncident);
Execution theCallingCallActivity = runtimeService.createExecutionQuery().activityId("theCallingCallActivity").singleResult();
assertNotNull(theCallingCallActivity);
assertNotNull(topLevelIncident.getId());
assertNotNull(topLevelIncident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, topLevelIncident.getIncidentType());
assertNull(topLevelIncident.getIncidentMessage());
assertEquals(theCallingCallActivity.getId(), topLevelIncident.getExecutionId());
assertEquals("theCallingCallActivity", topLevelIncident.getActivityId());
assertEquals(processInstance.getId(), topLevelIncident.getProcessInstanceId());
assertEquals(causeIncident.getId(), topLevelIncident.getCauseIncidentId());
assertEquals(rootCauseIncident.getId(), topLevelIncident.getRootCauseIncidentId());
assertNull(topLevelIncident.getConfiguration());
assertNull(topLevelIncident.getJobDefinitionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateOneIncident.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn" })
public void testShouldCreateOneIncident() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(incident);
assertNotNull(incident.getId());
assertNotNull(incident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType());
assertEquals(AlwaysFailingDelegate.MESSAGE, incident.getIncidentMessage());
assertEquals(processInstance.getId(), incident.getExecutionId());
assertEquals("theServiceTask", incident.getActivityId());
assertEquals(processInstance.getId(), incident.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), incident.getProcessDefinitionId());
assertEquals(incident.getId(), incident.getCauseIncidentId());
assertEquals(incident.getId(), incident.getRootCauseIncidentId());
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
assertEquals(job.getId(), incident.getConfiguration());
assertEquals(job.getJobDefinitionId(), incident.getJobDefinitionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MigrationEventBasedGatewayTest method testMigrateGatewayWithIncident.
@Test
public void testMigrateGatewayWithIncident() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "timerCatch").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId());
Job timerJob = rule.getManagementService().createJobQuery().singleResult();
// create an incident
rule.getManagementService().setJobRetries(timerJob.getId(), 0);
Incident incidentBeforeMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then job and incident still exist
testHelper.assertIntermediateTimerJobMigrated("timerCatch", "timerCatch");
Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0);
Incident incidentAfterMigration = rule.getRuntimeService().createIncidentQuery().singleResult();
assertNotNull(incidentAfterMigration);
assertEquals(incidentBeforeMigration.getId(), incidentAfterMigration.getId());
assertEquals(jobAfterMigration.getId(), incidentAfterMigration.getConfiguration());
assertEquals("timerCatch", incidentAfterMigration.getActivityId());
assertEquals(targetProcessDefinition.getId(), incidentAfterMigration.getProcessDefinitionId());
// and it is possible to complete the process
rule.getManagementService().executeJob(jobAfterMigration.getId());
testHelper.completeTask("afterTimerCatch");
testHelper.assertProcessEnded(processInstance.getId());
}
Aggregations