use of org.jbpm.kie.services.test.objects.TestQueryParamBuilderFactory in project jbpm by kiegroup.
the class QueryServiceImplTest method testGetProcessInstancesWithQueryParamBuilder.
@Test
public void testGetProcessInstancesWithQueryParamBuilder() {
query = new SqlQueryDefinition("getAllProcessInstances", dataSourceJNDIname);
query.setExpression("select * from processinstancelog");
queryService.registerQuery(query);
Collection<ProcessInstanceDesc> instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
QueryParamBuilderFactory qbFactory = new TestQueryParamBuilderFactory();
assertTrue(qbFactory.accept("test"));
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("min", processInstanceId);
parameters.put("max", processInstanceId + 2);
QueryParamBuilder<?> paramBuilder = qbFactory.newInstance(parameters);
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), paramBuilder);
assertNotNull(instances);
assertEquals(1, instances.size());
parameters = new HashMap<String, Object>();
parameters.put("min", processInstanceId + 2);
parameters.put("max", 0l);
paramBuilder = qbFactory.newInstance(parameters);
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), paramBuilder);
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
Aggregations