use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class HistoricVariableInstanceTest method testSimpleNoWaitState.
@Deployment
public void testSimpleNoWaitState() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc");
assertProcessEnded(processInstance.getId());
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list();
assertThat(variables).hasSize(1);
HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0);
assertThat(historicVariable.getTextValue()).isEqualTo("test456");
assertThat(historyService.createHistoricActivityInstanceQuery().count()).isEqualTo(4);
assertThat(historyService.createHistoricDetailQuery().count()).isEqualTo(2);
}
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class HistoricVariableInstanceTest method testHistoricVariableQueryByTaskIdsForScope.
@Deployment(resources = { "org/activiti/engine/test/api/runtime/variableScope.bpmn20.xml" })
public void testHistoricVariableQueryByTaskIdsForScope() {
Map<String, Object> processVars = new HashMap<String, Object>();
processVars.put("processVar", "processVar");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("variableScopeProcess", processVars);
Set<String> executionIds = new HashSet<String>();
List<Execution> executions = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).list();
for (Execution execution : executions) {
if (!processInstance.getId().equals(execution.getId())) {
executionIds.add(execution.getId());
runtimeService.setVariableLocal(execution.getId(), "executionVar", "executionVar");
}
}
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
Set<String> taskIds = new HashSet<String>();
for (Task task : tasks) {
taskService.setVariableLocal(task.getId(), "taskVar", "taskVar");
taskIds.add(task.getId());
}
List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().taskIds(taskIds).list();
assertThat(2).isEqualTo(historicVariableInstances.size());
assertThat("taskVar").isEqualTo(historicVariableInstances.get(0).getVariableName());
assertThat("taskVar").isEqualTo(historicVariableInstances.get(0).getValue());
assertThat("taskVar").isEqualTo(historicVariableInstances.get(1).getVariableName());
assertThat("taskVar").isEqualTo(historicVariableInstances.get(1).getValue());
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class CustomFlowExecutionListenerTest method testScriptExecutionListener.
@Deployment(resources = { "org/activiti/examples/bpmn/executionlistener/CustomFlowExecutionListenerTest.bpmn20.xml" })
public void testScriptExecutionListener() {
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("customFlowBean", new CustomFlowBean());
runtimeService.startProcessInstanceByKey("scriptExecutionListenerProcess", variableMap);
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("flow1_activiti_conditions").singleResult();
assertThat(variable).isNotNull();
assertThat(variable.getVariableName()).isEqualTo("flow1_activiti_conditions");
@SuppressWarnings("unchecked") List<String> conditions = (List<String>) variable.getValue();
assertThat(conditions).hasSize(2);
assertThat(conditions.get(0)).isEqualTo("hello");
assertThat(conditions.get(1)).isEqualTo("world");
}
use of org.activiti.engine.history.HistoricVariableInstance 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();
assertThat(variableInstances).hasSize(4);
for (HistoricVariableInstance variable : variableInstances) {
assertThat(variable.getValue()).isEqualTo(variables.get(variable.getVariableName()));
}
}
use of org.activiti.engine.history.HistoricVariableInstance 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();
assertThat(variableInstances).hasSize(0);
}
Aggregations