Search in sources :

Example 41 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testQueryWithReadPermissionOnAnyProcessInstance.

public void testQueryWithReadPermissionOnAnyProcessInstance() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 7);
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery)

Example 42 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testQueryForStandaloneIncidents.

public void testQueryForStandaloneIncidents() {
    // given
    disableAuthorization();
    repositoryService.suspendProcessDefinitionByKey(ONE_INCIDENT_PROCESS_KEY, true, new Date());
    String jobId = null;
    List<Job> jobs = managementService.createJobQuery().list();
    for (Job job : jobs) {
        if (job.getProcessDefinitionKey() == null) {
            jobId = job.getId();
            break;
        }
    }
    managementService.setJobRetries(jobId, 0);
    enableAuthorization();
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 1);
    disableAuthorization();
    managementService.deleteJob(jobId);
    enableAuthorization();
    clearDatabase();
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date)

Example 43 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testQueryWithReadInstancesPermissionOnOneTaskProcess.

public void testQueryWithReadInstancesPermissionOnOneTaskProcess() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_INSTANCE);
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 3);
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery)

Example 44 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentAuthorizationTest method testQueryWithoutAuthorization.

public void testQueryWithoutAuthorization() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    startProcessAndExecuteJob(ANOTHER_ONE_INCIDENT_PROCESS_KEY);
    // when
    IncidentQuery query = runtimeService.createIncidentQuery();
    // then
    verifyQueryResults(query, 0);
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery)

Example 45 with IncidentQuery

use of org.camunda.bpm.engine.runtime.IncidentQuery in project camunda-bpm-platform by camunda.

the class IncidentQueryTest method testQueryByIncidentMessage.

@Test
public void testQueryByIncidentMessage() {
    IncidentQuery query = runtimeService.createIncidentQuery().incidentMessage("Expected_exception.");
    assertEquals(4, query.count());
    List<Incident> incidents = query.list();
    assertFalse(incidents.isEmpty());
    assertEquals(4, incidents.size());
}
Also used : IncidentQuery(org.camunda.bpm.engine.runtime.IncidentQuery) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test)

Aggregations

IncidentQuery (org.camunda.bpm.engine.runtime.IncidentQuery)55 Incident (org.camunda.bpm.engine.runtime.Incident)34 Test (org.junit.Test)21 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 IncidentQueryDto (org.camunda.bpm.engine.rest.dto.runtime.IncidentQueryDto)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)1 RuntimeServiceImpl (org.camunda.bpm.engine.impl.RuntimeServiceImpl)1 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 IncidentDto (org.camunda.bpm.engine.rest.dto.runtime.IncidentDto)1 Execution (org.camunda.bpm.engine.runtime.Execution)1 Job (org.camunda.bpm.engine.runtime.Job)1