Search in sources :

Example 1 with TestQueryParamBuilderFactory

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;
}
Also used : TestQueryParamBuilderFactory(org.jbpm.kie.services.test.objects.TestQueryParamBuilderFactory) QueryParamBuilderFactory(org.jbpm.services.api.query.QueryParamBuilderFactory) HashMap(java.util.HashMap) SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) QueryContext(org.kie.api.runtime.query.QueryContext) TestQueryParamBuilderFactory(org.jbpm.kie.services.test.objects.TestQueryParamBuilderFactory) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)1 TestQueryParamBuilderFactory (org.jbpm.kie.services.test.objects.TestQueryParamBuilderFactory)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)1 QueryParamBuilderFactory (org.jbpm.services.api.query.QueryParamBuilderFactory)1 Test (org.junit.Test)1 AdvancedQueryContext (org.kie.api.runtime.query.AdvancedQueryContext)1 QueryContext (org.kie.api.runtime.query.QueryContext)1