Search in sources :

Example 6 with QueryContext

use of org.kie.internal.query.QueryContext in project jbpm by kiegroup.

the class EThreadInfoTest method getStackTrace.

// ========== PRIVATE METHODS ==========
private Collection<VariableDesc> getStackTrace(Long pid) {
    QueryContext query = new QueryContext();
    query.setOrderBy("id");
    query.setAscending(false);
    return runtimeDataService.getVariableHistory(pid, "stackTrace", query);
}
Also used : QueryContext(org.kie.internal.query.QueryContext)

Example 7 with QueryContext

use of org.kie.internal.query.QueryContext in project jbpm by kiegroup.

the class EThreadInfoTest method getThreadName.

private Collection<VariableDesc> getThreadName(Long pid) {
    QueryContext query = new QueryContext();
    query.setOrderBy("id");
    query.setAscending(false);
    return runtimeDataService.getVariableHistory(pid, "threadName", query);
}
Also used : QueryContext(org.kie.internal.query.QueryContext)

Example 8 with QueryContext

use of org.kie.internal.query.QueryContext in project jbpm by kiegroup.

the class EThreadInfoTest method testRESTThreadInfo.

@Test
public void testRESTThreadInfo() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("url", RestService.PING_URL);
    parameters.put("method", "GET");
    Long pid = startProcessInstance(THREAD_INFO_PROCESS_ID, parameters);
    processService.signalProcessInstance(pid, "start", "rest");
    listener.waitTillCompleted();
    Assertions.assertThat(hasNodeLeft(pid, "rest")).isTrue();
    Assertions.assertThat(hasNodeLeft(pid, "REST")).isTrue();
    Collection<VariableDesc> result = runtimeDataService.getVariableHistory(pid, "result", new QueryContext());
    Assertions.assertThat(result).hasSize(1);
    Assertions.assertThat(result.iterator().next().getNewValue()).isEqualTo("pong");
    Collection<VariableDesc> status = runtimeDataService.getVariableHistory(pid, "status", new QueryContext());
    Assertions.assertThat(status).hasSize(1);
    Assertions.assertThat(status.iterator().next().getNewValue()).isEqualTo("200");
    Collection<VariableDesc> statusMsg = runtimeDataService.getVariableHistory(pid, "statusMsg", new QueryContext());
    Assertions.assertThat(statusMsg).hasSize(1);
    Assertions.assertThat(statusMsg.iterator().next().getNewValue()).contains("successfully completed Ok");
    Collection<VariableDesc> stackTraceHistory = getStackTrace(pid);
    Collection<VariableDesc> threadNameHistory = getThreadName(pid);
    System.out.println("====stackTraceHistory====");
    System.out.println(stackTraceHistory);
    System.out.println("====stackTraceHistoryLast====");
    System.out.println(stackTraceHistory.iterator().next().getNewValue());
    System.out.println("====stackTraceHistorySize====");
    System.out.println(stackTraceHistory.size());
    System.out.println("====threadNameHistory====");
    System.out.println(threadNameHistory);
    System.out.println("====threadNameHistoryLast====");
    System.out.println(threadNameHistory.iterator().next().getNewValue());
    Assertions.assertThat(threadNameHistory.iterator().next().getNewValue()).startsWith("EE");
}
Also used : HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) QueryContext(org.kie.internal.query.QueryContext) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) Test(org.junit.Test)

Example 9 with QueryContext

use of org.kie.internal.query.QueryContext 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 10 with QueryContext

use of org.kie.internal.query.QueryContext in project jbpm by kiegroup.

the class EGetProcessInstanceTest method getProcessInstancesByDeploymentId.

@Test()
public void getProcessInstancesByDeploymentId() throws NamingException {
    EJBClient ejbClient2 = new EJBClient(TestKjars.BPMN_BUILD_TEST.getGav());
    startProcess("org.jboss.qa.bpms.HumanTask", new HashMap<>(), 3);
    startProcess("org.jboss.qa.bpms.HumanTaskWithOwnType", new HashMap<>(), 5);
    ejbClient2.startProcess("bpmnBuildTest.myProcess");
    List<Integer> states = new ArrayList<>();
    states.add(ProcessInstance.STATE_ACTIVE);
    List<ProcessInstanceDesc> foundList = ejb.getProcessInstancesByDeploymentId(TestKjars.INTEGRATION.getGav(), states, new QueryContext());
    Assertions.assertThat(foundList).hasSize(8);
    for (ProcessInstanceDesc pid : foundList) {
        Assertions.assertThat(pid.getProcessName()).isIn("HumanTask", "HumanTaskWithOwnType");
    }
}
Also used : EJBClient(org.jbpm.remote.ejb.test.client.EJBClient) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.internal.query.QueryContext) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Aggregations

QueryContext (org.kie.internal.query.QueryContext)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)5 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)4 AbstractRuntimeEJBServicesTest (org.jbpm.test.container.AbstractRuntimeEJBServicesTest)3 HashMap (java.util.HashMap)2 VariableDesc (org.jbpm.services.api.model.VariableDesc)2 UserTransaction (javax.transaction.UserTransaction)1 EJBClient (org.jbpm.remote.ejb.test.client.EJBClient)1 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)1 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)1 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)1 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)1 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)1