Search in sources :

Example 11 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testStartTimerJobIncidentQueryWithoutAuthorization.

// historic incident query (start timer job incident) //////////////////////////////
public void testStartTimerJobIncidentQueryWithoutAuthorization() {
    // given
    disableAuthorization();
    String jobId = managementService.createJobQuery().singleResult().getId();
    managementService.setJobRetries(jobId, 0);
    enableAuthorization();
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 0);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 12 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testSimpleQueryWithoutAuthorization.

// historic incident query ///////////////////////////////////////////
public void testSimpleQueryWithoutAuthorization() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 0);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 13 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testSimpleQueryWithReadHistoryPermissionOnProcessDefinition.

public void testSimpleQueryWithReadHistoryPermissionOnProcessDefinition() {
    // given
    startProcessAndExecuteJob(ONE_INCIDENT_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ONE_INCIDENT_PROCESS_KEY, userId, READ_HISTORY);
    // when
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 1);
}
Also used : HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery)

Example 14 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentAuthorizationTest method testQueryForStandaloneHistoricIncidents.

// historic incident query (standalone) //////////////////////////////
public void testQueryForStandaloneHistoricIncidents() {
    // 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
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery();
    // then
    verifyQueryResults(query, 1);
    disableAuthorization();
    managementService.deleteJob(jobId);
    enableAuthorization();
    clearDatabase();
}
Also used : Job(org.camunda.bpm.engine.runtime.Job) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery) Date(java.util.Date)

Example 15 with HistoricIncidentQuery

use of org.camunda.bpm.engine.history.HistoricIncidentQuery in project camunda-bpm-platform by camunda.

the class HistoricIncidentTest method testDoNotCreateNewIncident.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneFailingServiceProcess.bpmn20.xml" })
public void testDoNotCreateNewIncident() {
    startProcessInstance(PROCESS_DEFINITION_KEY);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().singleResult();
    HistoricIncidentQuery query = historyService.createHistoricIncidentQuery().processInstanceId(pi.getId());
    HistoricIncident incident = query.singleResult();
    assertNotNull(incident);
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
    // set retries to 1 by job definition id
    managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 1);
    // the incident still exists
    HistoricIncident tmp = query.singleResult();
    assertEquals(incident.getId(), tmp.getId());
    assertNull(tmp.getEndTime());
    assertTrue(tmp.isOpen());
    // execute the available job (should fail again)
    executeAvailableJobs();
    // the incident still exists and there
    // should be not a new incident
    assertEquals(1, query.count());
    tmp = query.singleResult();
    assertEquals(incident.getId(), tmp.getId());
    assertNull(tmp.getEndTime());
    assertTrue(tmp.isOpen());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncidentQuery(org.camunda.bpm.engine.history.HistoricIncidentQuery) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricIncidentQuery (org.camunda.bpm.engine.history.HistoricIncidentQuery)61 Test (org.junit.Test)29 Deployment (org.camunda.bpm.engine.test.Deployment)20 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)13 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)7 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)6 Date (java.util.Date)4 Job (org.camunda.bpm.engine.runtime.Job)4 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)2 HistoricIncidentQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricIncidentQueryDto)2 Incident (org.camunda.bpm.engine.runtime.Incident)2 ArrayList (java.util.ArrayList)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricIncidentDto (org.camunda.bpm.engine.rest.dto.history.HistoricIncidentDto)1