use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ProcessDefinitionQueryTest method testQueryByIncidentType.
@org.camunda.bpm.engine.test.Deployment(resources = { "org/camunda/bpm/engine/test/api/repository/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentType() {
assertEquals(1, repositoryService.createProcessDefinitionQuery().processDefinitionKey("failingProcess").count());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
List<Incident> incidentList = runtimeService.createIncidentQuery().list();
assertEquals(1, incidentList.size());
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().incidentType(incident.getIncidentType());
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testQueryByIncidentMessage.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentMessage() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
List<Incident> incidentList = runtimeService.createIncidentQuery().list();
assertEquals(1, incidentList.size());
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
List<Execution> executionList = runtimeService.createExecutionQuery().incidentMessage(incident.getIncidentMessage()).list();
assertEquals(1, executionList.size());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class CreateAndResolveIncidentTest method createIncidentWithIncidentHandler.
@Test
public void createIncidentWithIncidentHandler() {
// given
testRule.deploy(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
// when
Incident incident = runtimeService.createIncident("custom", processInstance.getId(), "configuration");
// then
assertNotNull(incident);
Incident incident2 = runtimeService.createIncidentQuery().singleResult();
assertNotNull(incident2);
assertEquals(incident, incident2);
assertEquals("custom", incident.getIncidentType());
assertEquals("configuration", incident.getConfiguration());
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class CreateAndResolveIncidentTest method resolveIncident.
@Test
public void resolveIncident() {
// given
testRule.deploy(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
Incident incident = runtimeService.createIncident("foo", processInstance.getId(), "userTask1", "bar");
// when
runtimeService.resolveIncident(incident.getId());
// then
Incident incident2 = runtimeService.createIncidentQuery().executionId(processInstance.getId()).singleResult();
assertNull(incident2);
}
use of org.camunda.bpm.engine.runtime.Incident in project camunda-bpm-platform by camunda.
the class CreateAndResolveIncidentTest method resolveIncidentOfTypeFailedJob.
@Test
public void resolveIncidentOfTypeFailedJob() {
// given
testRule.deploy("org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldCreateOneIncident.bpmn");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
// when
List<Job> jobs = engineRule.getManagementService().createJobQuery().withRetriesLeft().list();
for (Job job : jobs) {
engineRule.getManagementService().setJobRetries(job.getId(), 1);
try {
engineRule.getManagementService().executeJob(job.getId());
} catch (Exception e) {
}
}
// then
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
try {
runtimeService.resolveIncident(incident.getId());
fail("Exception expected");
} catch (BadUserRequestException e) {
assertThat(e.getMessage(), containsString("Cannot resolve an incident of type failedJob"));
}
}
Aggregations