use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByInvalidSuperCaseInstanceId.
@Test
public void testQueryByInvalidSuperCaseInstanceId() {
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
assertNull(query.superProcessInstanceId("invalid").singleResult());
assertEquals(0, query.superProcessInstanceId("invalid").list().size());
try {
query.superCaseInstanceId(null);
fail();
} catch (NullValueException e) {
// expected
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByProcessInstanceIds.
@Test
public void testQueryByProcessInstanceIds() {
Set<String> processInstanceIds = new HashSet<String>(this.processInstanceIds);
// start an instance that will not be part of the query
runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_2, "2");
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);
assertEquals(5, processInstanceQuery.count());
List<ProcessInstance> processInstances = processInstanceQuery.list();
assertNotNull(processInstances);
assertEquals(5, processInstances.size());
for (ProcessInstance processInstance : processInstances) {
assertTrue(processInstanceIds.contains(processInstance.getId()));
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryAllVariableTypes.
@Test
@Deployment(resources = { "org/camunda/bpm/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);
Assert.assertEquals(1, processInstances.size());
Assert.assertEquals(processInstance.getId(), processInstances.get(0).getId());
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryNoSpecificsSingleResult.
@Test
public void testQueryNoSpecificsSingleResult() {
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
try {
query.singleResult();
fail();
} catch (ProcessEngineException e) {
// Exception is expected
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByInvalidSubCaseInstanceId.
@Test
public void testQueryByInvalidSubCaseInstanceId() {
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
assertNull(query.subProcessInstanceId("invalid").singleResult());
assertEquals(0, query.subProcessInstanceId("invalid").list().size());
try {
query.subCaseInstanceId(null);
fail();
} catch (NullValueException e) {
// expected
}
}
Aggregations