use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceAndVariablesQueryTest method testOrQuery.
public void testOrQuery() {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("undefined", 999).variableValueEquals("anothertest", 123).endOr().singleResult();
Map<String, Object> variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));
processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("undefined", 999).endOr().singleResult();
assertNull(processInstance);
processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123).variableValueEquals("undefined", 999).endOr().singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));
processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 999).endOr().singleResult();
assertNull(processInstance);
processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 999).variableValueEquals("anothertest", 123).endOr().singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceAndVariablesQueryTest method testOrQueryMultipleVariableValues.
public void testOrQueryMultipleVariableValues() {
ProcessInstanceQuery query0 = runtimeService.createProcessInstanceQuery().includeProcessVariables().or();
for (int i = 0; i < 20; i++) {
query0 = query0.variableValueEquals("anothertest", i);
}
query0 = query0.endOr();
assertNull(query0.singleResult());
ProcessInstanceQuery query1 = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123);
for (int i = 0; i < 20; i++) {
query1 = query1.variableValueEquals("anothertest", i);
}
query1 = query1.endOr();
assertNull(query0.singleResult());
ProcessInstance processInstance = query1.singleResult();
Map<String, Object> variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));
ProcessInstanceQuery query2 = runtimeService.createProcessInstanceQuery().includeProcessVariables().or();
for (int i = 0; i < 20; i++) {
query2 = query2.variableValueEquals("anothertest", i);
}
query2 = query2.endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr();
assertNull(query2.singleResult());
ProcessInstanceQuery query3 = runtimeService.createProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123);
for (int i = 0; i < 20; i++) {
query3 = query3.variableValueEquals("anothertest", i);
}
query3 = query3.endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr();
variableMap = query3.singleResult().getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceQueryAndWithExceptionTest method testQueryWithException.
public void testQueryWithException() throws InterruptedException {
ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
ProcessInstanceQuery queryNoException = runtimeService.createProcessInstanceQuery();
assertEquals(1, queryNoException.count());
assertEquals(1, queryNoException.list().size());
assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());
ProcessInstanceQuery queryWithException = runtimeService.createProcessInstanceQuery();
assertEquals(0, queryWithException.withJobException().count());
assertEquals(0, queryWithException.withJobException().list().size());
ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
JobQuery jobQuery1 = managementService.createJobQuery().processInstanceId(processWithException1.getId());
assertEquals(1, jobQuery1.withException().count());
assertEquals(1, jobQuery1.withException().list().size());
assertEquals(1, queryWithException.withJobException().count());
assertEquals(1, queryWithException.withJobException().list().size());
assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());
ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
JobQuery jobQuery2 = managementService.createJobQuery().processInstanceId(processWithException2.getId());
assertEquals(2, jobQuery2.withException().count());
assertEquals(2, jobQuery2.withException().list().size());
assertEquals(2, queryWithException.withJobException().count());
assertEquals(2, queryWithException.withJobException().list().size());
assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ProcessInstanceQueryTest method testQueryAllVariableTypes.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryAllVariableTypes() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("nullVar", null);
vars.put("stringVar", "string");
vars.put("longVar", 10L);
vars.put("doubleVar", 1.2);
vars.put("integerVar", 1234);
vars.put("booleanVar", true);
vars.put("shortVar", (short) 123);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().variableValueEquals("nullVar", null).variableValueEquals("stringVar", "string").variableValueEquals("longVar", 10L).variableValueEquals("doubleVar", 1.2).variableValueEquals("integerVar", 1234).variableValueEquals("booleanVar", true).variableValueEquals("shortVar", (short) 123);
List<ProcessInstance> processInstances = query.list();
assertNotNull(processInstances);
assertEquals(1, processInstances.size());
assertEquals(processInstance.getId(), processInstances.get(0).getId());
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.
the class ExecutionQueryTest method testQueryInvalidTypes.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryInvalidTypes() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("bytesVar", "test".getBytes());
vars.put("serializableVar", new DummySerializable());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
try {
runtimeService.createExecutionQuery().variableValueEquals("bytesVar", "test".getBytes()).list();
fail("Expected exception");
} catch (ActivitiIllegalArgumentException ae) {
assertTextPresent("Variables of type ByteArray cannot be used to query", ae.getMessage());
}
try {
runtimeService.createExecutionQuery().variableValueEquals("serializableVar", new DummySerializable()).list();
fail("Expected exception");
} catch (ActivitiIllegalArgumentException ae) {
assertTextPresent("Variables of type ByteArray cannot be used to query", ae.getMessage());
}
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
Aggregations