Search in sources :

Example 81 with QueryContext

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);
}
Also used : QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 82 with QueryContext

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

Example 83 with QueryContext

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());
}
Also used : QueryContext(org.kie.api.runtime.query.QueryContext) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 84 with QueryContext

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();
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ReleaseId(org.kie.api.builder.ReleaseId) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) File(java.io.File) Before(org.junit.Before)

Example 85 with QueryContext

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

Aggregations

QueryContext (org.kie.api.runtime.query.QueryContext)315 Test (org.junit.Test)299 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)131 HashMap (java.util.HashMap)115 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)109 ArrayList (java.util.ArrayList)99 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)67 RequestInfo (org.kie.api.executor.RequestInfo)53 TaskSummary (org.kie.api.task.model.TaskSummary)53 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)51 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)49 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)45 CommandContext (org.kie.api.executor.CommandContext)39 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)37 UserImpl (org.jbpm.services.task.impl.model.UserImpl)37 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)36 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)34 QueryFilter (org.kie.internal.query.QueryFilter)30 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)29 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)29