use of org.jbpm.services.api.query.QueryParamBuilderFactory in project jbpm by kiegroup.
the class UserTaskInstanceWithPotOwnerTest method testSearchTaskByPotOwnerQueryParamBuilder.
@Test
public void testSearchTaskByPotOwnerQueryParamBuilder() {
query = new SqlQueryDefinition("jbpmHumanTasksPO", dataSourceJNDIname);
query.setExpression("select t.actualowner_id as actualowner, t.CREATEDBY_ID as createdby, t.CREATEDON as CREATEDON, t.EXPIRATIONTIME as expirationDate, " + "t.id as TASKID, t.name as NAME, t.priority as PRIORITY, t.PROCESSINSTANCEID as PROCESSINSTANCEID, t.PROCESSID as PROCESSID, t.STATUS as STATUS, " + "po.entity_id as POTOWNER, t.FORMNAME AS FORMNAME, p.processinstancedescription as PROCESSINSTANCEDESCRIPTION, t.subject as SUBJECT, t.deploymentid as DEPLOYMENTID " + "from TASK t " + "inner join PEOPLEASSIGNMENTS_POTOWNERS po on t.id=po.task_id " + "inner join PROCESSINSTANCELOG p on t.processinstanceid = p.processinstanceid");
queryService.registerQuery(query);
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "initial content");
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
List<UserTaskInstanceWithPotOwnerDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceWithPotOwnerQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
assertNotNull(taskInstanceLogs.get(0).getProcessInstanceDescription());
QueryParamBuilderFactory qbFactory = new UserTaskPotOwnerQueryBuilderFactory();
assertTrue(qbFactory.accept("potOwnerBuilder"));
List<String> potOwners = new ArrayList<String>();
potOwners.add("salaboy");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("potOwner", potOwners);
QueryParamBuilder<?> paramBuilder = qbFactory.newInstance(parameters);
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceWithPotOwnerQueryMapper.get(), new QueryContext(), paramBuilder);
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
potOwners = new ArrayList<String>();
potOwners.add("wrongPotOwner");
parameters = new HashMap<String, Object>();
parameters.put("potOwner", potOwners);
paramBuilder = qbFactory.newInstance(parameters);
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceWithPotOwnerQueryMapper.get(), new QueryContext(), paramBuilder);
assertNotNull(taskInstanceLogs);
assertEquals(0, taskInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.services.api.query.QueryParamBuilderFactory 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