Search in sources :

Example 56 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class ProcessServiceImplTest method testStartProcessCallActivityCheckNodes.

@Test
public void testStartProcessCallActivityCheckNodes() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "ParentProcess");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(processInstanceId);
    assertNotNull(pi);
    Collection<ProcessInstanceDesc> children = runtimeDataService.getProcessInstancesByParent(processInstanceId, null, new QueryContext());
    assertNotNull(children);
    assertEquals(1, children.size());
    ProcessInstanceDesc childInstance = children.iterator().next();
    assertNotNull(childInstance);
    assertEquals("org.jbpm.signal", childInstance.getProcessId());
    Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstanceDesc activeNode = activeNodes.iterator().next();
    assertNotNull(activeNode);
    assertEquals("SubProcessNode", activeNode.getNodeType());
    assertEquals(childInstance.getId(), activeNode.getReferenceId());
    processService.signalProcessInstance(childInstance.getId(), "MySignal", null);
    children = runtimeDataService.getProcessInstancesByParent(processInstanceId, Arrays.asList(2, 3), new QueryContext());
    assertNotNull(children);
    assertEquals(1, children.size());
    childInstance = children.iterator().next();
    assertNotNull(childInstance);
    assertEquals("org.jbpm.signal", childInstance.getProcessId());
    pi = processService.getProcessInstance(processInstanceId);
    assertNull(pi);
    Collection<NodeInstanceDesc> completedNodes = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, new QueryContext());
    assertNotNull(completedNodes);
    assertEquals(3, completedNodes.size());
    NodeInstanceDesc completedNode = completedNodes.stream().filter(n -> n.getNodeType().equals("SubProcessNode")).findFirst().orElse(null);
    assertNotNull(completedNode);
    assertEquals("SubProcessNode", completedNode.getNodeType());
    assertEquals(childInstance.getId(), completedNode.getReferenceId());
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 57 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class QueryServiceImplTest method testGetFilteredProcessInstances.

@Test
public void testGetFilteredProcessInstances() {
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    identityProvider.setRoles(roles);
    query = new SqlQueryDefinition("getAllProcessInstances", dataSourceJNDIname, Target.FILTERED_PROCESS);
    query.setExpression("select * from processinstancelog");
    queryService.registerQuery(query);
    List<QueryDefinition> queries = queryService.getQueries(new QueryContext());
    assertNotNull(queries);
    assertEquals(1, queries.size());
    QueryDefinition registeredQuery = queryService.getQuery(query.getName());
    assertNotNull(registeredQuery);
    assertEquals(query.getName(), registeredQuery.getName());
    assertEquals(query.getSource(), registeredQuery.getSource());
    assertEquals(query.getExpression(), registeredQuery.getExpression());
    assertEquals(query.getTarget(), registeredQuery.getTarget());
    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);
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(1, (int) instances.iterator().next().getState());
    // let's now change the roles so user should not see instances
    roles.clear();
    roles.add("employees");
    identityProvider.setRoles(roles);
    identityProvider.setName("anotherUser2");
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
}
Also used : SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) QueryDefinition(org.jbpm.services.api.query.model.QueryDefinition) SqlQueryDefinition(org.jbpm.kie.services.impl.query.SqlQueryDefinition) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) AdvancedQueryContext(org.kie.api.runtime.query.AdvancedQueryContext) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 58 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class QueryServiceImplTest method testGetProcessInstancesByProcessId.

@Test
public void testGetProcessInstancesByProcessId() {
    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);
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.likeTo(COLUMN_PROCESSID, true, "org.jbpm%"));
    assertNotNull(instances);
    assertEquals(1, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 59 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class QueryServiceImplTest method testGetProcessInstancesByState.

@Test
public void testGetProcessInstancesByState() {
    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);
    // search for aborted only
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // aborted and active
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3, 1));
    assertNotNull(instances);
    assertEquals(1, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    // aborted only
    instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(3, (int) instances.iterator().next().getState());
}
Also used : 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 60 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstanceByIdNoAccess.

@Test
public void testGetProcessInstanceByIdNoAccess() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceById(processInstanceId);
    assertNotNull(instance);
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceById(processInstanceId);
    processInstanceId = null;
    assertNotNull(instance);
}
Also used : 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)

Aggregations

ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)198 Test (org.junit.Test)147 QueryContext (org.kie.api.runtime.query.QueryContext)123 ArrayList (java.util.ArrayList)75 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)57 HashMap (java.util.HashMap)32 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)25 TaskSummary (org.kie.api.task.model.TaskSummary)25 QueryFilter (org.kie.internal.query.QueryFilter)23 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)17 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)16 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)15 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)12 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)12 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 CorrelationKey (org.kie.internal.process.CorrelationKey)11 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)9 List (java.util.List)7