Search in sources :

Example 11 with NodeInstance

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

the class ProcessInstanceAdminServiceIntegrationTest method testRetrigger.

@Test
public void testRetrigger() 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.retriggerNodeInstance(CONTAINER_ID, processInstanceId, active.getId());
        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) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 12 with NodeInstance

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

the class KieClientServicesIntegrationTest method testSolverServiceCamelProducer.

@Test
public void testSolverServiceCamelProducer() throws Exception {
    MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
    mockEndpoint.expectedMessageCount(1);
    Map<String, Object> headers = new HashMap<>();
    headers.put(KIE_CLIENT, "solver");
    headers.put(KIE_OPERATION, "getSolvers");
    headers.put(asCamelKieName("containerId"), "my-container");
    template.sendBodyAndHeaders("direct:start", null, headers);
    assertMockEndpointsSatisfied();
    List<NodeInstance> nodeInstanceList = getResultMessage(mockEndpoint.getExchanges().get(0)).getBody(List.class);
    assertCollectionSize(nodeInstanceList, 0);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) HashMap(java.util.HashMap) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Test(org.junit.Test)

Example 13 with NodeInstance

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

the class KieClientServicesIntegrationTest method testQueryServiceCamelProducer.

@Test
public void testQueryServiceCamelProducer() throws Exception {
    MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
    mockEndpoint.expectedMessageCount(1);
    Map<String, Object> headers = new HashMap<>();
    headers.put(KIE_CLIENT, "query");
    headers.put(KIE_OPERATION, "findCompletedNodeInstances");
    headers.put(asCamelKieName("processInstanceId"), 100L);
    headers.put(asCamelKieName("page"), 1);
    headers.put(asCamelKieName("pageSize"), 10);
    template.sendBodyAndHeaders("direct:start", null, headers);
    assertMockEndpointsSatisfied();
    List<NodeInstance> nodeInstanceList = getResultMessage(mockEndpoint.getExchanges().get(0)).getBody(List.class);
    assertCollectionSize(nodeInstanceList, 0);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) HashMap(java.util.HashMap) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Test(org.junit.Test)

Example 14 with NodeInstance

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

the class ConvertUtils method convertToNodeInstanceList.

public static NodeInstanceList convertToNodeInstanceList(Collection<NodeInstanceDesc> definitions) {
    if (definitions == null) {
        return new NodeInstanceList(new NodeInstance[0]);
    }
    List<NodeInstance> processes = new ArrayList<NodeInstance>(definitions.size());
    for (NodeInstanceDesc ni : definitions) {
        NodeInstance nodeInstance = convertToNodeInstance(ni);
        processes.add(nodeInstance);
    }
    return new NodeInstanceList(processes);
}
Also used : ArrayList(java.util.ArrayList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) NodeInstance(org.kie.server.api.model.instance.NodeInstance) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc)

Example 15 with NodeInstance

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

the class RuntimeDataServiceIntegrationTest method testGetNodeInstances.

@Test
public void testGetNodeInstances() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("stringData", "waiting for signal");
    parameters.put("personData", createPersonInstance(USER_JOHN));
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
    try {
        List<NodeInstance> instances = queryClient.findActiveNodeInstances(processInstanceId, 0, 10);
        assertNotNull(instances);
        assertEquals(1, instances.size());
        NodeInstance expectedFirstTask = NodeInstance.builder().name("First task").containerId(CONTAINER_ID).nodeType("HumanTaskNode").completed(false).processInstanceId(processInstanceId).build();
        NodeInstance nodeInstance = instances.get(0);
        assertNodeInstance(expectedFirstTask, nodeInstance);
        assertNotNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
        nodeInstance = queryClient.findNodeInstanceByWorkItemId(processInstanceId, nodeInstance.getWorkItemId());
        assertNodeInstance(expectedFirstTask, nodeInstance);
        assertNotNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
        instances = queryClient.findCompletedNodeInstances(processInstanceId, 0, 10);
        assertNotNull(instances);
        assertEquals(1, instances.size());
        NodeInstance expectedStart = NodeInstance.builder().name("start").containerId(CONTAINER_ID).nodeType("StartNode").completed(true).processInstanceId(processInstanceId).build();
        nodeInstance = instances.get(0);
        assertNodeInstance(expectedStart, nodeInstance);
        assertNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
        instances = queryClient.findNodeInstances(processInstanceId, 0, 10);
        assertNotNull(instances);
        assertEquals(3, instances.size());
        nodeInstance = instances.get(0);
        assertNodeInstance(expectedFirstTask, nodeInstance);
        assertNotNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
        nodeInstance = instances.get(1);
        assertNodeInstance(expectedStart, nodeInstance);
        assertNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
        nodeInstance = instances.get(2);
        expectedStart.setCompleted(false);
        assertNodeInstance(expectedStart, nodeInstance);
        assertNull(nodeInstance.getWorkItemId());
        assertNotNull(nodeInstance.getDate());
    } finally {
        processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
    }
}
Also used : HashMap(java.util.HashMap) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Test(org.junit.Test)

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