Search in sources :

Example 31 with HistoricActivityInstanceQuery

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

the class HistoricActivityInstanceTest method testUserTaskStillRunning.

@Deployment
public void testUserTaskStillRunning() {
    runtimeService.startProcessInstanceByKey("nonInterruptingEvent");
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    managementService.executeJob(jobQuery.singleResult().getId());
    HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("userTask");
    assertEquals(1, historicActivityInstanceQuery.count());
    assertNull(historicActivityInstanceQuery.singleResult().getEndTime());
    historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end1");
    assertEquals(0, historicActivityInstanceQuery.count());
    historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("timer");
    assertEquals(1, historicActivityInstanceQuery.count());
    assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
    historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end2");
    assertEquals(1, historicActivityInstanceQuery.count());
    assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with HistoricActivityInstanceQuery

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

the class HistoricVariableInstanceScopeTest method testInputMappings.

@Deployment
public void testInputMappings() {
    // given
    String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
    HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId);
    String theService1Id = activityInstanceQuery.activityId("theService1").singleResult().getId();
    String theService2Id = activityInstanceQuery.activityId("theService2").singleResult().getId();
    String theTaskId = activityInstanceQuery.activityId("theTask").singleResult().getId();
    // when (1)
    HistoricVariableInstance firstVariable = historyService.createHistoricVariableInstanceQuery().variableName("firstInputVariable").singleResult();
    // then (1)
    assertEquals(theService1Id, firstVariable.getActivityInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricDetail firstVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(firstVariable.getId()).singleResult();
        assertEquals(theService1Id, firstVariableDetail.getActivityInstanceId());
    }
    // when (2)
    HistoricVariableInstance secondVariable = historyService.createHistoricVariableInstanceQuery().variableName("secondInputVariable").singleResult();
    // then (2)
    assertEquals(theService2Id, secondVariable.getActivityInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricDetail secondVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(secondVariable.getId()).singleResult();
        assertEquals(theService2Id, secondVariableDetail.getActivityInstanceId());
    }
    // when (3)
    HistoricVariableInstance thirdVariable = historyService.createHistoricVariableInstanceQuery().variableName("thirdInputVariable").singleResult();
    // then (3)
    assertEquals(theTaskId, thirdVariable.getActivityInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricDetail thirdVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(thirdVariable.getId()).singleResult();
        assertEquals(theTaskId, thirdVariableDetail.getActivityInstanceId());
    }
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 33 with HistoricActivityInstanceQuery

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

the class HistoricActivityInstanceRestServiceImpl method queryHistoricActivityInstances.

@Override
public List<HistoricActivityInstanceDto> queryHistoricActivityInstances(HistoricActivityInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
    queryDto.setObjectMapper(objectMapper);
    HistoricActivityInstanceQuery query = queryDto.toQuery(processEngine);
    List<HistoricActivityInstance> matchingHistoricActivityInstances;
    if (firstResult != null || maxResults != null) {
        matchingHistoricActivityInstances = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingHistoricActivityInstances = query.list();
    }
    List<HistoricActivityInstanceDto> historicActivityInstanceResults = new ArrayList<HistoricActivityInstanceDto>();
    for (HistoricActivityInstance historicActivityInstance : matchingHistoricActivityInstances) {
        HistoricActivityInstanceDto resultHistoricActivityInstance = HistoricActivityInstanceDto.fromHistoricActivityInstance(historicActivityInstance);
        historicActivityInstanceResults.add(resultHistoricActivityInstance);
    }
    return historicActivityInstanceResults;
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery) ArrayList(java.util.ArrayList) HistoricActivityInstanceDto(org.camunda.bpm.engine.rest.dto.history.HistoricActivityInstanceDto) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 34 with HistoricActivityInstanceQuery

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

the class HistoricActivityInstanceAuthorizationTest method testQueryWithReadHistoryPermissionOnAnyProcessDefinition.

public void testQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // then
    verifyQueryResults(query, 14);
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)

Example 35 with HistoricActivityInstanceQuery

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

the class HistoricActivityInstanceAuthorizationTest method testQueryWithoutAuthorization.

// historic activity instance query (multiple process instances) ////////////////////////
public void testQueryWithoutAuthorization() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    // when
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // then
    verifyQueryResults(query, 0);
}
Also used : HistoricActivityInstanceQuery(org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)

Aggregations

HistoricActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)59 Deployment (org.camunda.bpm.engine.test.Deployment)35 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 Task (org.camunda.bpm.engine.task.Task)18 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)17 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)13 Execution (org.camunda.bpm.engine.runtime.Execution)4 Test (org.junit.Test)4 Job (org.camunda.bpm.engine.runtime.Job)3 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)3 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)3 Response (com.jayway.restassured.response.Response)2 ArrayList (java.util.ArrayList)2 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 InOrder (org.mockito.InOrder)2 HashMap (java.util.HashMap)1 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)1 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1