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());
}
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());
}
}
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;
}
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);
}
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);
}
Aggregations