use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testActivityIdProperty.
@Deployment
public void testActivityIdProperty() {
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertNotNull(incident.getActivityId());
assertEquals("theStart", incident.getActivityId());
assertNull(incident.getProcessInstanceId());
assertNull(incident.getExecutionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testIncidentUpdateAfterCompaction.
@Deployment
public void testIncidentUpdateAfterCompaction() {
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
executeAvailableJobs();
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertNotSame(processInstanceId, incident.getExecutionId());
runtimeService.correlateMessage("Message");
incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
// incident updated with new execution id after execution tree is compacted
assertEquals(processInstanceId, incident.getExecutionId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldDeleteIncidentAfterJobWasSuccessfully.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldDeleteIncidentAfterJobWasSuccessfully.bpmn" })
public void testShouldDeleteIncidentAfterJobWasSuccessfully() {
// Start process instance
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcessWithUserTask", parameters);
executeAvailableJobs();
// job exists
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
// incident was created
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(incident);
// set execution variable from "true" to "false"
runtimeService.setVariable(processInstance.getId(), "fail", new Boolean(false));
// set retries of failed job to 1, with the change of the fail variable the job
// will be executed successfully
managementService.setJobRetries(job.getId(), 1);
executeAvailableJobs();
// Update process instance
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertTrue(processInstance instanceof ExecutionEntity);
// should stay in the user task
ExecutionEntity exec = (ExecutionEntity) processInstance;
assertEquals("theUserTask", exec.getActivityId());
// there does not exist any incident anymore
incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
assertNull(incident);
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testBoundaryEventIncidentActivityId.
public void testBoundaryEventIncidentActivityId() {
deployment(Bpmn.createExecutableProcess("process").startEvent().userTask("userTask").endEvent().moveToActivity("userTask").boundaryEvent("boundaryEvent").timerWithDuration("PT5S").endEvent().done());
// given
runtimeService.startProcessInstanceByKey("process");
Job timerJob = managementService.createJobQuery().singleResult();
// when creating an incident
managementService.setJobRetries(timerJob.getId(), 0);
// then
Incident incident = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident);
assertEquals("boundaryEvent", incident.getActivityId());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class IncidentTest method testShouldCreateOneIncidentAfterExecuteJob.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn" })
public void testShouldCreateOneIncidentAfterExecuteJob() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
List<Incident> incidents = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).list();
assertFalse(incidents.isEmpty());
assertTrue(incidents.size() == 1);
Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(job);
// set job retries to 1 -> should fail again and a second incident should be created
try {
managementService.executeJob(job.getId());
fail("Exception was expected.");
} catch (ProcessEngineException e) {
// exception expected
}
incidents = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).list();
// There is still one incident
assertFalse(incidents.isEmpty());
assertTrue(incidents.size() == 1);
}
Aggregations