Search in sources :

Example 6 with NodeInstanceDesc

use of org.jbpm.services.api.model.NodeInstanceDesc 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 7 with NodeInstanceDesc

use of org.jbpm.services.api.model.NodeInstanceDesc 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 8 with NodeInstanceDesc

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

the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndCompleteWorkItem.

@Test
public void testStartProcessAndCompleteWorkItem() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    assertEquals("Write a Document", activeNodes.iterator().next().getName());
    Map<String, Object> outcome = new HashMap<String, Object>();
    outcome.put("Result", "here is my first document");
    processService.completeWorkItem(deploymentUnit.getIdentifier(), processInstanceId, activeNodes.iterator().next().getWorkItemId(), outcome);
    activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(2, activeNodes.size());
    Object variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_document");
    assertNotNull(variableValue);
    assertTrue(variableValue instanceof String);
    assertEquals("here is my first document", variableValue);
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) 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 9 with NodeInstanceDesc

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

the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndGetWorkItem.

@Test
public void testStartProcessAndGetWorkItem() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    assertEquals("Write a Document", activeNodes.iterator().next().getName());
    WorkItem wi = processService.getWorkItem(deploymentUnit.getIdentifier(), processInstanceId, activeNodes.iterator().next().getWorkItemId());
    assertNotNull(wi);
    assertEquals("Human Task", wi.getName());
    assertEquals("Write a Document", wi.getParameter("NodeName"));
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) WorkItem(org.kie.api.runtime.process.WorkItem) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 10 with NodeInstanceDesc

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

the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndAbortWorkItem.

@Test
public void testStartProcessAndAbortWorkItem() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    assertEquals("Write a Document", activeNodes.iterator().next().getName());
    processService.abortWorkItem(deploymentUnit.getIdentifier(), processInstanceId, activeNodes.iterator().next().getWorkItemId());
    activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(2, activeNodes.size());
    Object variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_document");
    assertNull(variableValue);
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) 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)

Aggregations

NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)45 Test (org.junit.Test)40 QueryContext (org.kie.api.runtime.query.QueryContext)29 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)20 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)19 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)15 HashMap (java.util.HashMap)14 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)12 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)9 TaskSummary (org.kie.api.task.model.TaskSummary)9 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)8 WorkItem (org.kie.api.runtime.process.WorkItem)8 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)7 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)6 QueryFilter (org.kie.internal.query.QueryFilter)6 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)4 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)4 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)4 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)4 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)4