Search in sources :

Example 1 with HistoricActivityInstanceQuery

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);
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 2 with HistoricActivityInstanceQuery

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());
    }
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) HashMap(java.util.HashMap) HistoricVariableInstanceQuery(org.activiti.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 3 with HistoricActivityInstanceQuery

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());
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) HashMap(java.util.HashMap) HistoricVariableInstanceQuery(org.activiti.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 4 with HistoricActivityInstanceQuery

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());
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance) Deployment(org.activiti.engine.test.Deployment)

Example 5 with HistoricActivityInstanceQuery

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());
}
Also used : HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery)

Aggregations

HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)4 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)3 HashMap (java.util.HashMap)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)2 HistoricVariableInstanceQuery (org.activiti.engine.history.HistoricVariableInstanceQuery)2 Deployment (org.activiti.engine.test.Deployment)2 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)1