Search in sources :

Example 36 with Incident

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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) Incident(org.camunda.bpm.engine.runtime.Incident)

Example 37 with Incident

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());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 38 with Incident

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());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 39 with Incident

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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Example 40 with Incident

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"));
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Job(org.camunda.bpm.engine.runtime.Job) ExpectedException(org.junit.rules.ExpectedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

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