use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testGetProcessInstancesWithQueryDataServiceUsingCustomMapper.
@Test
public void testGetProcessInstancesWithQueryDataServiceUsingCustomMapper() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
List<Long> processInstanceIds = createProcessInstances(parameters);
QueryDefinition query = createQueryDefinition("CUSTOM");
try {
queryClient.registerQuery(query);
List<ProcessInstance> instances = queryClient.query(query.getName(), "CustomMapper", 0, 10, ProcessInstance.class);
assertNotNull(instances);
assertEquals(5, instances.size());
List<Long> found = collectInstances(instances);
assertEquals(processInstanceIds, found);
instances = queryClient.query(query.getName(), "CustomMapper", 0, 3, ProcessInstance.class);
assertNotNull(instances);
assertEquals(3, instances.size());
instances = queryClient.query(query.getName(), "CustomMapper", "status", 1, 3, ProcessInstance.class);
assertNotNull(instances);
assertEquals(2, instances.size());
} finally {
abortProcessInstances(processInstanceIds);
queryClient.unregisterQuery(query.getName());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testGetProcessInstancesWithQueryDataServiceUsingCustomQueryBuilderAndColumnMapping.
@Test
public void testGetProcessInstancesWithQueryDataServiceUsingCustomQueryBuilderAndColumnMapping() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
List<Long> processInstanceIds = createProcessInstances(parameters);
QueryDefinition query = getProcessInstanceWithVariablesQueryDefinition();
try {
queryClient.registerQuery(query);
Map<String, String> columnMapping = new HashMap<>();
columnMapping.put("variableId", "String");
columnMapping.put("value", "String");
Map<String, Object> params = new HashMap<String, Object>();
params.put("min", processInstanceIds.get(4));
params.put("max", processInstanceIds.get(0));
params.put(KieServerConstants.QUERY_ORDER_BY, "processInstanceId");
params.put(KieServerConstants.QUERY_ASCENDING, false);
params.put(KieServerConstants.QUERY_COLUMN_MAPPING, columnMapping);
List<ProcessInstance> instances = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_WITH_CUSTOM_VARS, "test", params, 0, 10, ProcessInstance.class);
assertNotNull(instances);
assertEquals(2, instances.size());
long pi1 = instances.get(0).getId();
long pi2 = instances.get(1).getId();
// since sort order is descending first should be instance id which is bigger then second
assertTrue(pi1 > pi2);
for (ProcessInstance instance : instances) {
final Map<String, Object> variables = instance.getVariables();
assertNotNull(variables);
assertEquals(2, variables.size());
assertTrue(variables.containsKey("variableId"));
assertTrue(variables.containsKey("value"));
}
} finally {
abortProcessInstances(processInstanceIds);
queryClient.unregisterQuery(query.getName());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testQueryDataServiceUsingComplexCustomQueryBuilderFilterSpecWithOrderByClause.
@Test
public void testQueryDataServiceUsingComplexCustomQueryBuilderFilterSpecWithOrderByClause() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
List<Long> processInstanceIds = createProcessInstances(parameters);
final QueryDefinition query = getProcessInstanceWithVariablesQueryDefinition();
try {
queryClient.registerQuery(query);
QueryParam expression = or(equalsTo("PROCESSINSTANCEID", processInstanceIds.get(0)), equalsTo("PROCESSINSTANCEID", processInstanceIds.get(1)));
QueryFilterSpec filterSpec = QueryFilterSpec.builder().where(expression).get();
List<ProcessInstance> instances = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_WITH_VARS, filterSpec, 0, 10, ProcessInstance.class);
assertNotNull(instances);
assertEquals(2, instances.size());
} finally {
abortProcessInstances(processInstanceIds);
queryClient.unregisterQuery(query.getName());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testGetProcessInstancesWithOrderByClause.
/*
* JBPM-5468 Client requests with 'sortBy' request parameter can now use full ORDER BY clause syntax.
*/
@Test
public void testGetProcessInstancesWithOrderByClause() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
List<Long> processInstanceIds = createProcessInstances(parameters);
QueryDefinition query = createQueryDefinition("CUSTOM");
try {
queryClient.registerQuery(query);
List<ProcessInstance> instances = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI, "processId asc, processInstanceId desc", 0, 10, ProcessInstance.class);
assertNotNull(instances);
assertEquals(5, instances.size());
List<Long> found = collectInstances(instances);
assertEquals(processInstanceIds, found);
long pi1 = instances.get(0).getId();
long pi2 = instances.get(1).getId();
// since sort order is descending first should be instance id which is bigger then second
assertTrue(pi1 + " not greater than " + pi2, pi1 > pi2);
} finally {
abortProcessInstances(processInstanceIds);
queryClient.unregisterQuery(query.getName());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryDataServiceIntegrationTest method testGetProcessInstancesWithVariablesQueryDataService.
@Test
public void testGetProcessInstancesWithVariablesQueryDataService() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
parameters.put("nullAccepted", true);
List<Long> processInstanceIds = createProcessInstances(parameters);
final QueryDefinition query = getProcessInstanceWithVariablesQueryDefinition();
try {
queryClient.registerQuery(query);
final List<ProcessInstance> instances = queryClient.query(query.getName(), QueryServicesClient.QUERY_MAP_PI_WITH_VARS, 0, 20, ProcessInstance.class);
assertNotNull(instances);
final List<Long> found = collectInstances(instances);
assertEquals(processInstanceIds, found);
for (ProcessInstance instance : instances) {
final Map<String, Object> variables = instance.getVariables();
assertNotNull(variables);
assertEquals(4, variables.size());
assertEquals(TestConfig.getUsername(), variables.get("initiator"));
assertEquals("waiting for signal", variables.get("stringData"));
assertEquals("Person{name='john'}", variables.get("personData"));
assertEquals("true", variables.get("nullAccepted"));
}
} finally {
abortProcessInstances(processInstanceIds);
queryClient.unregisterQuery(query.getName());
}
}
Aggregations