use of org.jbpm.kie.services.impl.query.builder.UserTaskPotOwnerQueryBuilderFactory 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;
}
Aggregations