Search in sources :

Example 21 with NodeInstance

use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceAdminServiceIntegrationTest method testCancelAndTrigger.

@Test
public void testCancelAndTrigger() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    Long processInstanceId = null;
    try {
        processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, parameters);
        assertNotNull(processInstanceId);
        assertTrue(processInstanceId.longValue() > 0);
        List<NodeInstance> activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
        assertNotNull(activeNodeInstances);
        assertEquals(1, activeNodeInstances.size());
        NodeInstance active = activeNodeInstances.get(0);
        assertEquals("Evaluate items?", active.getName());
        processAdminClient.cancelNodeInstance(CONTAINER_ID, processInstanceId, active.getId());
        activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
        assertNotNull(activeNodeInstances);
        assertEquals(0, activeNodeInstances.size());
        List<ProcessNode> processNodes = processAdminClient.getProcessNodes(CONTAINER_ID, processInstanceId);
        ProcessNode first = processNodes.stream().filter(pn -> pn.getNodeName().equals("Evaluate items?")).findFirst().orElse(null);
        assertNotNull(first);
        processAdminClient.triggerNode(CONTAINER_ID, processInstanceId, first.getNodeId());
        activeNodeInstances = processAdminClient.getActiveNodeInstances(CONTAINER_ID, processInstanceId);
        assertNotNull(activeNodeInstances);
        assertEquals(1, activeNodeInstances.size());
        NodeInstance activeTriggered = activeNodeInstances.get(0);
        assertEquals("Evaluate items?", activeTriggered.getName());
        assertFalse(activeTriggered.getId().longValue() == active.getId().longValue());
    } finally {
        if (processInstanceId != null) {
            processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
        }
    }
}
Also used : HashMap(java.util.HashMap) ProcessNode(org.kie.server.api.model.admin.ProcessNode) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 22 with NodeInstance

use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.

the class CaseRuntimeDataServiceIntegrationTest method testCreateCaseWithCaseFileAndDynamicActivities.

@Test
public void testCreateCaseWithCaseFileAndDynamicActivities() {
    String caseId = startUserTaskCase(USER_JOHN, USER_YODA);
    assertNotNull(caseId);
    assertTrue(caseId.startsWith(CASE_HR_ID_PREFIX));
    List<NodeInstance> activeNodes = caseClient.getActiveNodes(CONTAINER_ID, caseId, 0, 10);
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance activeNode = activeNodes.get(0);
    assertNotNull(activeNode);
    assertEquals("Hello1", activeNode.getName());
    List<NodeInstance> completedNodes = caseClient.getCompletedNodes(CONTAINER_ID, caseId, 0, 10);
    assertNotNull(completedNodes);
    assertEquals(0, completedNodes.size());
    List<ProcessInstance> instances = caseClient.getActiveProcessInstances(CONTAINER_ID, caseId, 0, 10);
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ProcessInstance pi = instances.get(0);
    assertEquals(CASE_HR_DEF_ID, pi.getProcessId());
    assertEquals(caseId, pi.getCorrelationKey());
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("input", "text data");
    caseClient.addDynamicUserTask(CONTAINER_ID, caseId, "dynamic task", "simple description", USER_YODA, null, parameters);
    List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
    assertEquals(1, tasks.size());
    TaskSummary task = tasks.get(0);
    assertEquals("dynamic task", task.getName());
    assertEquals("simple description", task.getDescription());
    assertEquals(Status.Reserved.toString(), task.getStatus());
    assertEquals(USER_YODA, task.getActualOwner());
    activeNodes = caseClient.getActiveNodes(CONTAINER_ID, caseId, 0, 10);
    assertNotNull(activeNodes);
    assertEquals(2, activeNodes.size());
    List<String> nodeNames = activeNodes.stream().map(n -> n.getName()).collect(toList());
    assertTrue(nodeNames.contains("[Dynamic] dynamic task"));
    assertTrue(nodeNames.contains("Hello1"));
    taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null);
    completedNodes = caseClient.getCompletedNodes(CONTAINER_ID, caseId, 0, 10);
    assertNotNull(completedNodes);
    assertEquals(1, completedNodes.size());
    NodeInstance completedNode = completedNodes.get(0);
    assertNotNull(completedNode);
    assertEquals("[Dynamic] dynamic task", completedNode.getName());
    caseClient.addDynamicSubProcess(CONTAINER_ID, caseId, "DataVerification", parameters);
    instances = caseClient.getProcessInstances(CONTAINER_ID, caseId, Arrays.asList(1, 2, 3), 0, 10);
    assertNotNull(instances);
    assertEquals(2, instances.size());
}
Also used : Arrays(java.util.Arrays) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) BiFunction(java.util.function.BiFunction) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) Reserved(org.kie.api.task.model.Status.Reserved) CaseInstance(org.kie.server.api.model.cases.CaseInstance) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) After(org.junit.After) Assertions(org.assertj.core.api.Assertions) CaseServicesClient(org.kie.server.client.CaseServicesClient) Assert.fail(org.junit.Assert.fail) Ready(org.kie.api.task.model.Status.Ready) TaskSummary(org.kie.server.api.model.instance.TaskSummary) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Collection(java.util.Collection) CaseComment(org.kie.server.api.model.cases.CaseComment) Collectors(java.util.stream.Collectors) CaseRoleAssignment(org.kie.server.api.model.cases.CaseRoleAssignment) List(java.util.List) CaseFileDataItem(org.kie.server.api.model.cases.CaseFileDataItem) CaseAdHocFragment(org.kie.server.api.model.cases.CaseAdHocFragment) CaseDefinition(org.kie.server.api.model.cases.CaseDefinition) Assert.assertFalse(org.junit.Assert.assertFalse) Status(org.kie.api.task.model.Status) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest) KieServicesException(org.kie.server.api.exception.KieServicesException) BeforeClass(org.junit.BeforeClass) STATE_ACTIVE(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE) CaseStage(org.kie.server.api.model.cases.CaseStage) HashMap(java.util.HashMap) Function(java.util.function.Function) CaseFile(org.kie.server.api.model.cases.CaseFile) ArrayList(java.util.ArrayList) KieServerAssert(org.kie.server.integrationtests.shared.KieServerAssert) KieServices(org.kie.api.KieServices) Assume(org.junit.Assume) STATE_ABORTED(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED) CaseMilestone(org.kie.server.api.model.cases.CaseMilestone) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) KieServerDeployer(org.kie.server.integrationtests.shared.KieServerDeployer) TestConfig(org.kie.server.integrationtests.config.TestConfig) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) STATE_COMPLETED(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED) Collectors.toList(java.util.stream.Collectors.toList) Assert.assertNull(org.junit.Assert.assertNull) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) ReleaseId(org.kie.server.api.model.ReleaseId) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) TaskSummary(org.kie.server.api.model.instance.TaskSummary) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) NodeInstance(org.kie.server.api.model.instance.NodeInstance) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest) Test(org.junit.Test)

Example 23 with NodeInstance

use of org.kie.server.api.model.instance.NodeInstance in project droolsjbpm-integration by kiegroup.

the class CaseManagementRuntimeDataServiceBase method getCompletedNodes.

public NodeInstanceList getCompletedNodes(String containerId, String caseId, Integer page, Integer pageSize) {
    Collection<NodeInstanceDesc> completedNodeInstances = caseRuntimeDataService.getCompletedNodesForCase(caseId, ConvertUtils.buildQueryContext(page, pageSize));
    List<NodeInstance> completedNodes = ConvertUtils.transformNodeInstance(completedNodeInstances);
    NodeInstanceList completedNodesList = new NodeInstanceList(completedNodes);
    return completedNodesList;
}
Also used : NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) NodeInstance(org.kie.server.api.model.instance.NodeInstance) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList)

Aggregations

NodeInstance (org.kie.server.api.model.instance.NodeInstance)23 Test (org.junit.Test)16 HashMap (java.util.HashMap)12 TaskSummary (org.kie.server.api.model.instance.TaskSummary)6 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)4 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)4 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)3 ArrayList (java.util.ArrayList)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 Category (org.junit.experimental.categories.Category)2 CorrelationKey (org.kie.internal.process.CorrelationKey)2 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1