use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessIds.
@Test
public void testGetProcessIds() {
Collection<String> definitions = runtimeDataService.getProcessIds(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(definitions);
assertEquals(5, definitions.size());
assertTrue(definitions.contains("org.jbpm.writedocument.empty"));
assertTrue(definitions.contains("org.jbpm.writedocument"));
assertTrue(definitions.contains("UserTask"));
assertTrue(definitions.contains("org.jboss.qa.bpms.HumanTask"));
assertTrue(definitions.contains("AdHocSubProcess"));
String origVer = deploymentUnit.getVersion();
deploymentUnit.setVersion("LATEST");
definitions = runtimeDataService.getProcessIds(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(definitions);
assertEquals(5, definitions.size());
assertTrue(definitions.contains("org.jbpm.writedocument.empty"));
assertTrue(definitions.contains("AdHocSubProcess"));
deploymentUnit.setVersion(origVer);
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstancesByState.
@Test
public void testGetProcessInstancesByState() {
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Integer> states = new ArrayList<Integer>();
// search for aborted only
states.add(3);
instances = runtimeDataService.getProcessInstances(states, null, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstances(states, null, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(3, (int) instances.iterator().next().getState());
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetProcessInstanceHistoryAdHocSubprocess.
@Test
public void testGetProcessInstanceHistoryAdHocSubprocess() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "AdHocSubProcess");
assertNotNull(processInstanceId);
processService.signalProcessInstance(processInstanceId, "Hello1", null);
// get active nodes as history view
Collection<NodeInstanceDesc> instances = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(2, instances.size());
// get completed nodes as history view
instances = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
// get both active and completed nodes as history view
instances = runtimeDataService.getProcessInstanceFullHistory(processInstanceId, new QueryContext());
assertNotNull(instances);
assertEquals(4, instances.size());
// get nodes filtered by type - start
instances = runtimeDataService.getProcessInstanceFullHistoryByType(processInstanceId, EntryType.START, new QueryContext());
assertNotNull(instances);
assertEquals(3, instances.size());
// get nodes filtered by type - end
instances = runtimeDataService.getProcessInstanceFullHistoryByType(processInstanceId, EntryType.END, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class TaskVariablesQueryServiceTest method prepare.
@Before
public void prepare() {
configureServices();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
File kjar = new File("src/test/resources/kjar-task-vars/task-vars-1.0.jar");
File pom = new File("src/test/resources/kjar-task-vars/pom.xml");
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kjar, pom);
ReleaseId releaseIdSales = ks.newReleaseId("org.jbpm.test", "product-sale", "1.0");
File kjarSales = new File("src/test/resources/kjar-sales/product-sale-1.0.jar");
File pomSales = new File("src/test/resources/kjar-sales/pom.xml");
repository.installArtifact(releaseIdSales, kjarSales, pomSales);
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
KModuleDeploymentUnit deploymentUnitSales = new KModuleDeploymentUnit(SALES_GROUP_ID, SALES_ARTIFACT_ID, SALES_VERSION);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addMarshalingStrategy(new ObjectModel("mvel", "new org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy(\"org.jbpm.test:product-sale:1.0\", classLoader)"));
// disable below line to avoid jpa marshaling of ProductSale variable
deploymentUnitSales.setDeploymentDescriptor(customDescriptor);
deploymentService.deploy(deploymentUnitSales);
deploymentUnitSalesId = deploymentUnitSales.getIdentifier();
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
deploymentUnitId = deploymentUnit.getIdentifier();
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class UserTaskInstanceWithPotOwnerTest method testSearchTaskByPotOwnerMapper.
@Test
public void testSearchTaskByPotOwnerMapper() {
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());
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceWithPotOwnerQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_POTOWNER, wrongUser));
assertNotNull(taskInstanceLogs);
assertEquals(0, taskInstanceLogs.size());
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceWithPotOwnerQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_POTOWNER, correctUser));
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
Aggregations