use of org.activiti.engine.runtime.ProcessInstanceQuery in project Activiti by Activiti.
the class StartTimerEventTest method testCycleDateStartTimerEvent.
// FIXME: This test likes to run in an endless loop when invoking the waitForJobExecutorOnCondition method
@Deployment
public void testCycleDateStartTimerEvent() throws Exception {
processEngineConfiguration.getClock().setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
final ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 1 == piq.count();
}
});
assertEquals(1, jobQuery.count());
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 2 == piq.count();
}
});
assertEquals(1, jobQuery.count());
//have to manually delete pending timer
cleanDB();
}
use of org.activiti.engine.runtime.ProcessInstanceQuery 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.ProcessInstanceQuery 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.ProcessInstanceQuery 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.ProcessInstanceQuery in project Activiti by Activiti.
the class ProcessInstanceQueryTest method testQueryByProcessDefinitionKeySingleResult.
public void testQueryByProcessDefinitionKeySingleResult() {
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_2);
assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query.count());
assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query.list().size());
assertNotNull(query.singleResult());
}
Aggregations