use of org.activiti.engine.history.HistoricActivityInstanceQuery in project Activiti by Activiti.
the class HistoricActivityInstanceTest method testHistoricActivityInstanceUnfinished.
@Deployment
public void testHistoricActivityInstanceUnfinished() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertNotNull(processInstance);
HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
long finishedActivityInstanceCount = historicActivityInstanceQuery.finished().count();
assertEquals("The Start event is completed", 1, finishedActivityInstanceCount);
long unfinishedActivityInstanceCount = historicActivityInstanceQuery.unfinished().count();
assertEquals("One active (unfinished) User Task", 1, unfinishedActivityInstanceCount);
}
use of org.activiti.engine.history.HistoricActivityInstanceQuery in project Activiti by Activiti.
the class CallActivityTest method testInheritVariablesSubprocess.
public void testInheritVariablesSubprocess() throws Exception {
BpmnModel mainBpmnModel = loadBPMNModel(INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);
processEngine.getRepositoryService().createDeployment().name("mainProcessDeployment").addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();
processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("var1", "String test value");
variables.put("var2", true);
variables.put("var3", 12345);
variables.put("var4", 67890);
ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);
HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
activityInstanceQuery.activityId("childProcessCall");
HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
String calledInstanceId = activityInstance.getCalledProcessInstanceId();
HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
List<HistoricVariableInstance> variableInstances = variableInstanceQuery.processInstanceId(calledInstanceId).list();
assertEquals(4, variableInstances.size());
for (HistoricVariableInstance variable : variableInstances) {
assertEquals(variables.get(variable.getVariableName()), variable.getValue());
}
}
use of org.activiti.engine.history.HistoricActivityInstanceQuery in project Activiti by Activiti.
the class CallActivityTest method testNotInheritVariablesSubprocess.
public void testNotInheritVariablesSubprocess() throws Exception {
BpmnModel mainBpmnModel = loadBPMNModel(NOT_INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);
processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
processEngine.getRepositoryService().createDeployment().name("mainProcessDeployment").addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("var1", "String test value");
variables.put("var2", true);
variables.put("var3", 12345);
variables.put("var4", 67890);
ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);
HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
activityInstanceQuery.activityId("childProcessCall");
HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
String calledInstanceId = activityInstance.getCalledProcessInstanceId();
HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
variableInstanceQuery.processInstanceId(calledInstanceId);
List<HistoricVariableInstance> variableInstances = variableInstanceQuery.list();
assertEquals(0, variableInstances.size());
}
use of org.activiti.engine.history.HistoricActivityInstanceQuery in project Activiti by Activiti.
the class CompensateEventTest method testCompensationStepEndTimeRecorded.
@Deployment(resources = { "org/activiti/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationStepEndRecorded.bpmn20.xml" })
public void testCompensationStepEndTimeRecorded() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensationStepEndRecordedProcess");
assertProcessEnded(processInstance.getId());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
if (!processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
return;
}
final HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().activityId("compensationScriptTask");
assertEquals(1, query.count());
final HistoricActivityInstance compensationScriptTask = query.singleResult();
assertNotNull(compensationScriptTask);
assertNotNull(compensationScriptTask.getEndTime());
assertNotNull(compensationScriptTask.getDurationInMillis());
}
use of org.activiti.engine.history.HistoricActivityInstanceQuery in project Activiti by Activiti.
the class HistoricActivityInstanceEscapeClauseTest method testQueryByTenantIdLike.
public void testQueryByTenantIdLike() {
runtimeService.startProcessInstanceByKeyAndTenantId("noopProcess", "One%");
runtimeService.startProcessInstanceByKeyAndTenantId("noopProcess", "Two_");
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().activityId("noop").activityTenantIdLike("%\\%%");
assertEquals("One%", query.singleResult().getTenantId());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = historyService.createHistoricActivityInstanceQuery().activityId("noop").activityTenantIdLike("%\\_%");
assertEquals("Two_", query.singleResult().getTenantId());
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
Aggregations