Search in sources :

Example 31 with NodeInstanceDesc

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

the class EProcessHistoryTest method testNodeInstanceLogs.

@Test
public void testNodeInstanceLogs() {
    long pid = startProcess(ProcessDefinitions.SCRIPT_TASK);
    List<NodeInstanceDesc> logs = ejb.getProcessInstanceFullHistory(pid);
    Assertions.assertThat(logs.size()).isEqualTo(6);
    String[] expected = { "_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691", "_3C8F4385-5348-479C-83EE-0C2DC2004F1A", "_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9", "_DC07735C-FA99-414C-AEAC-9F4CE0CF24F9", "_3C8F4385-5348-479C-83EE-0C2DC2004F1A", "_A3185DDF-23A7-48B7-A2FE-7C0FE39F6691" };
    for (int i = 0; i < logs.size(); ++i) {
        NodeInstanceDesc node = logs.get(i);
        Assertions.assertThat(node.getNodeId()).isEqualTo(expected[i]);
    }
}
Also used : NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 32 with NodeInstanceDesc

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

the class EGetNodeInstanceTest method getNodeInstanceForWorkItem.

@Test()
public void getNodeInstanceForWorkItem() {
    Long pid = ejb.startProcess("org.jboss.qa.bpms.HumanTask");
    Long workItemId = null;
    List<NodeInstanceDesc> nodeList = ejb.getProcessInstanceHistoryActive(pid, new QueryContext());
    for (NodeInstanceDesc node : nodeList) {
        if (node.getName().equals("Hello")) {
            workItemId = node.getWorkItemId();
        }
    }
    if (workItemId == null) {
        throw new RuntimeException("Work item Id not found.");
    }
    NodeInstanceDesc nodeDesc = ejb.getNodeInstanceForWorkItem(workItemId);
    Assertions.assertThat(nodeDesc).isNotNull();
    Assertions.assertThat(nodeDesc.getDeploymentId()).isEqualTo(TestKjars.INTEGRATION.getGav());
    Assertions.assertThat(nodeDesc.getProcessInstanceId()).isEqualTo(pid);
    Assertions.assertThat(nodeDesc.getNodeId()).isEqualTo("_E4906EEE-6F73-4A8A-9E8E-E046EE35C10F");
    Assertions.assertThat(nodeDesc.getName()).isEqualTo("Hello");
    Assertions.assertThat(nodeDesc.getNodeType()).isEqualTo("HumanTaskNode");
    Assertions.assertThat(nodeDesc.isCompleted()).isFalse();
}
Also used : QueryContext(org.kie.internal.query.QueryContext) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 33 with NodeInstanceDesc

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

the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndGetWorkItems.

@Test
public void testStartProcessAndGetWorkItems() {
    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());
    List<WorkItem> wis = processService.getWorkItemByProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(wis);
    assertEquals(1, wis.size());
    assertEquals("Human Task", wis.get(0).getName());
    assertEquals("Write a Document", wis.get(0).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 34 with NodeInstanceDesc

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

the class ProcessServiceImplTest method testStartProcessAndCompleteWorkItemAfterDeactivation.

@Test
public void testStartProcessAndCompleteWorkItemAfterDeactivation() {
    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(processInstanceId);
    assertNotNull(pi);
    deploymentService.deactivate(deploymentUnit.getIdentifier());
    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(activeNodes.iterator().next().getWorkItemId(), outcome);
    activeNodes = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, new QueryContext());
    assertNotNull(activeNodes);
    assertEquals(2, activeNodes.size());
    Object variableValue = processService.getProcessInstanceVariable(processInstanceId, "approval_document");
    assertNotNull(variableValue);
    assertTrue(variableValue instanceof String);
    assertEquals("here is my first document", variableValue);
    processService.abortProcessInstance(processInstanceId);
    pi = processService.getProcessInstance(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 35 with NodeInstanceDesc

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

the class ProcessServiceImplTest 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(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(activeNodes.iterator().next().getWorkItemId());
    assertNotNull(wi);
    assertEquals("Human Task", wi.getName());
    assertEquals("Write a Document", wi.getParameter("NodeName"));
    processService.abortProcessInstance(processInstanceId);
    pi = processService.getProcessInstance(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)

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