use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createIncidentMock.
private void createIncidentMock() {
IncidentQuery mockIncidentQuery = mock(IncidentQuery.class);
List<Incident> incidents = MockProvider.createMockIncidents();
when(mockIncidentQuery.list()).thenReturn(incidents);
when(mockRuntimeService.createIncidentQuery()).thenReturn(mockIncidentQuery);
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MockProvider method createMockIncident.
public static Incident createMockIncident(String tenantId) {
Incident incident = mock(Incident.class);
when(incident.getId()).thenReturn(EXAMPLE_INCIDENT_ID);
when(incident.getIncidentTimestamp()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_INCIDENT_TIMESTAMP));
when(incident.getIncidentType()).thenReturn(EXAMPLE_INCIDENT_TYPE);
when(incident.getExecutionId()).thenReturn(EXAMPLE_INCIDENT_EXECUTION_ID);
when(incident.getActivityId()).thenReturn(EXAMPLE_INCIDENT_ACTIVITY_ID);
when(incident.getProcessInstanceId()).thenReturn(EXAMPLE_INCIDENT_PROC_INST_ID);
when(incident.getProcessDefinitionId()).thenReturn(EXAMPLE_INCIDENT_PROC_DEF_ID);
when(incident.getCauseIncidentId()).thenReturn(EXAMPLE_INCIDENT_CAUSE_INCIDENT_ID);
when(incident.getRootCauseIncidentId()).thenReturn(EXAMPLE_INCIDENT_ROOT_CAUSE_INCIDENT_ID);
when(incident.getConfiguration()).thenReturn(EXAMPLE_INCIDENT_CONFIGURATION);
when(incident.getIncidentMessage()).thenReturn(EXAMPLE_INCIDENT_MESSAGE);
when(incident.getTenantId()).thenReturn(tenantId);
when(incident.getJobDefinitionId()).thenReturn(EXAMPLE_JOB_DEFINITION_ID);
return incident;
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToFailedStartTimerIncident.
public void testPropagateTenantIdToFailedStartTimerIncident() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().timerWithDuration("PT1M").serviceTask().camundaExpression("${failing}").endEvent().done());
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertThat(incident, is(notNullValue()));
// inherit the tenant id from job
assertThat(incident.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToFailedExternalTaskIncident.
public void testPropagateTenantIdToFailedExternalTaskIncident() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().serviceTask().camundaType("external").camundaTopic("test").endEvent().done());
startProcessInstance(PROCESS_DEFINITION_KEY);
// fetch the external task and mark it as failed which create an incident
List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(1, "test-worker").topic("test", 1000).execute();
externalTaskService.handleFailure(tasks.get(0).getId(), "test-worker", "expected", 0, 0);
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertThat(incident, is(notNullValue()));
// inherit the tenant id from execution
assertThat(incident.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateRecursiveIncidents.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateRecursiveIncidents.bpmn", "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn" })
public void testShouldCreateRecursiveIncidents() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callFailingProcess");
executeAvailableJobs();
List<Incident> incidents = runtimeService.createIncidentQuery().list();
assertFalse(incidents.isEmpty());
assertTrue(incidents.size() == 2);
ProcessInstance failingProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("failingProcess").singleResult();
assertNotNull(failingProcess);
ProcessInstance callProcess = runtimeService.createProcessInstanceQuery().processDefinitionKey("callFailingProcess").singleResult();
assertNotNull(callProcess);
// Root cause incident
Incident causeIncident = runtimeService.createIncidentQuery().processDefinitionId(failingProcess.getProcessDefinitionId()).singleResult();
assertNotNull(causeIncident);
Job job = managementService.createJobQuery().executionId(causeIncident.getExecutionId()).singleResult();
assertNotNull(job);
assertNotNull(causeIncident.getId());
assertNotNull(causeIncident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, causeIncident.getIncidentType());
assertEquals(AlwaysFailingDelegate.MESSAGE, causeIncident.getIncidentMessage());
assertEquals(job.getExecutionId(), causeIncident.getExecutionId());
assertEquals("theServiceTask", causeIncident.getActivityId());
assertEquals(failingProcess.getId(), causeIncident.getProcessInstanceId());
assertEquals(causeIncident.getId(), causeIncident.getCauseIncidentId());
assertEquals(causeIncident.getId(), causeIncident.getRootCauseIncidentId());
assertEquals(job.getId(), causeIncident.getConfiguration());
assertEquals(job.getJobDefinitionId(), causeIncident.getJobDefinitionId());
// Recursive created incident
Incident recursiveCreatedIncident = runtimeService.createIncidentQuery().processDefinitionId(callProcess.getProcessDefinitionId()).singleResult();
assertNotNull(recursiveCreatedIncident);
Execution theCallActivityExecution = runtimeService.createExecutionQuery().activityId("theCallActivity").singleResult();
assertNotNull(theCallActivityExecution);
assertNotNull(recursiveCreatedIncident.getId());
assertNotNull(recursiveCreatedIncident.getIncidentTimestamp());
assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, recursiveCreatedIncident.getIncidentType());
assertNull(recursiveCreatedIncident.getIncidentMessage());
assertEquals(theCallActivityExecution.getId(), recursiveCreatedIncident.getExecutionId());
assertEquals("theCallActivity", recursiveCreatedIncident.getActivityId());
assertEquals(processInstance.getId(), recursiveCreatedIncident.getProcessInstanceId());
assertEquals(causeIncident.getId(), recursiveCreatedIncident.getCauseIncidentId());
assertEquals(causeIncident.getId(), recursiveCreatedIncident.getRootCauseIncidentId());
assertNull(recursiveCreatedIncident.getConfiguration());
assertNull(recursiveCreatedIncident.getJobDefinitionId());
}
Aggregations