use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testRemoveVariables.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testRemoveVariables() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("variable1", "value1");
vars.put("variable2", "value2");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
runtimeService.setVariable(processInstance.getId(), "variable3", "value3");
runtimeService.removeVariables(processInstance.getId(), vars.keySet());
assertNull(runtimeService.getVariable(processInstance.getId(), "variable1"));
assertNull(runtimeService.getVariableLocal(processInstance.getId(), "variable1"));
assertNull(runtimeService.getVariable(processInstance.getId(), "variable2"));
assertNull(runtimeService.getVariableLocal(processInstance.getId(), "variable2"));
assertEquals("value3", runtimeService.getVariable(processInstance.getId(), "variable3"));
assertEquals("value3", runtimeService.getVariableLocal(processInstance.getId(), "variable3"));
checkHistoricVariableUpdateEntity("variable1", processInstance.getId());
checkHistoricVariableUpdateEntity("variable2", processInstance.getId());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testSignalWithProcessVariables.
@Deployment
public void testSignalWithProcessVariables() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testSignalWithProcessVariables");
Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("variable", "value");
// signal the execution while passing in the variables
runtimeService.signal(processInstance.getId(), processVariables);
Map<String, Object> variables = runtimeService.getVariables(processInstance.getId());
assertEquals(variables, processVariables);
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testHistoricVariableRemovedWhenRuntimeVariableIsRemoved.
// Test for https://activiti.atlassian.net/browse/ACT-2186
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testHistoricVariableRemovedWhenRuntimeVariableIsRemoved() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("var1", "Hello");
vars.put("var2", "World");
vars.put("var3", "!");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Verify runtime
assertEquals(3, runtimeService.getVariables(processInstance.getId()).size());
assertEquals(3, runtimeService.getVariables(processInstance.getId(), Arrays.asList("var1", "var2", "var3")).size());
assertNotNull(runtimeService.getVariable(processInstance.getId(), "var2"));
// Verify history
assertEquals(3, historyService.createHistoricVariableInstanceQuery().list().size());
assertNotNull(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("var2").singleResult());
// Remove one variable
runtimeService.removeVariable(processInstance.getId(), "var2");
// Verify runtime
assertEquals(2, runtimeService.getVariables(processInstance.getId()).size());
assertEquals(2, runtimeService.getVariables(processInstance.getId(), Arrays.asList("var1", "var2", "var3")).size());
assertNull(runtimeService.getVariable(processInstance.getId(), "var2"));
// Verify history
assertEquals(2, historyService.createHistoricVariableInstanceQuery().list().size());
assertNull(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("var2").singleResult());
}
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ExecutionQueryTest method testClashingValues.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testClashingValues() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("var", 1234L);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
Map<String, Object> vars2 = new HashMap<String, Object>();
vars2.put("var", 1234);
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars2);
List<Execution> executions = runtimeService.createExecutionQuery().processDefinitionKey("oneTaskProcess").variableValueEquals("var", 1234L).list();
assertEquals(1, executions.size());
assertEquals(processInstance.getId(), executions.get(0).getProcessInstanceId());
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class InstanceInvolvementTest method testUserMultipleTimesinvolvedWithProcessInstance.
/**
* Test for ACT-1686
*/
@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testUserMultipleTimesinvolvedWithProcessInstance() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
// Add 2 links of a different type for the same user
runtimeService.addUserIdentityLink(processInstance.getId(), "kermit", "type1");
runtimeService.addUserIdentityLink(processInstance.getId(), "kermit", "type2");
assertEquals(1L, runtimeService.createProcessInstanceQuery().involvedUser("kermit").count());
}
Aggregations