Search in sources :

Example 1 with QueryContext

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

the class EDeploymentTest method testDeploy.

@Test
public void testDeploy() throws Exception {
    DeploymentUnit basicKieJar = archive.deployBasicKieJar();
    DeployedUnit deployed = deploymentService.getDeployedUnit(basicKieJar.getIdentifier());
    Assertions.assertThat(deployed).isNotNull();
    Assertions.assertThat(deployed.getDeploymentUnit()).isNotNull();
    Assertions.assertThat(deployed.getDeploymentUnit()).isEqualTo(basicKieJar);
    Assertions.assertThat(deployed.getRuntimeManager()).isNotNull();
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    Assertions.assertThat(processes).isNotNull().isNotEmpty();
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.internal.query.QueryContext) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) Test(org.junit.Test) AbstractEJBServicesTest(org.jbpm.test.container.AbstractEJBServicesTest)

Example 2 with QueryContext

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

the class ERestServiceTaskTest method testRestWorkItem.

@Test
public void testRestWorkItem() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("url", RestService.PING_URL);
    parameters.put("method", "GET");
    Long pid = processService.startProcess(kieJar, REST_WORK_ITEM_PROCESS_ID, parameters);
    Assertions.assertThat(pid).isNotNull();
    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");
}
Also used : HashMap(java.util.HashMap) VariableDesc(org.jbpm.services.api.model.VariableDesc) QueryContext(org.kie.internal.query.QueryContext) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 3 with QueryContext

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

the class ETransactionTest method testAbortProcessCommit.

@Test
public void testAbortProcessCommit() throws Exception {
    Long processInstanceId = startProcessInstance(PROCESS_ID);
    checkProcessInstanceIsActive(processInstanceId);
    UserTransaction ut = InitialContext.doLookup(USER_TRANSACTION_NAME);
    ut.begin();
    try {
        processService.abortProcessInstance(processInstanceId);
    } catch (Exception e) {
        ut.rollback();
        throw e;
    }
    ut.commit();
    List<Integer> states = new ArrayList<Integer>();
    states.add(ProcessInstance.STATE_ABORTED);
    Collection<ProcessInstanceDesc> processInstances = runtimeDataService.getProcessInstances(states, null, new QueryContext());
    Assertions.assertThat(processInstances).isNotNull().hasSize(1);
    Assertions.assertThat(processInstances.iterator().next().getId()).isEqualTo(processInstanceId);
}
Also used : UserTransaction(javax.transaction.UserTransaction) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.internal.query.QueryContext) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) Test(org.junit.Test)

Example 4 with QueryContext

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

the class RemoteEjbTest method abortAllProcesses.

protected static void abortAllProcesses() {
    List<Integer> stateList = new ArrayList<>();
    stateList.add(ProcessInstance.STATE_ACTIVE);
    QueryContext context = new QueryContext(0, Integer.MAX_VALUE, "log.status", true);
    List<ProcessInstanceDesc> instanceDescList = ejb.getProcessInstances(stateList, null, context);
    logger.info("Cleaning up ...");
    logger.info("\tFound '" + instanceDescList.size() + "' active instances.");
    for (ProcessInstanceDesc instanceDesc : instanceDescList) {
        logger.info("\tAborting process instance with id '" + instanceDesc.getId() + "' of type '" + instanceDesc.getProcessId() + "'");
        ejb.abortProcessInstance(instanceDesc.getId());
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.internal.query.QueryContext)

Example 5 with QueryContext

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

the class EGetProcessInstanceTest method getProcessInstancesByProcessName.

@Test()
public void getProcessInstancesByProcessName() {
    startProcess("org.jboss.qa.bpms.HumanTask", new HashMap<>(), 3);
    startProcess("org.jboss.qa.bpms.HumanTaskWithOwnType", new HashMap<>(), 5);
    List<Integer> states = new ArrayList<>();
    states.add(ProcessInstance.STATE_ACTIVE);
    List<ProcessInstanceDesc> foundList = ejb.getProcessInstancesByProcessName(states, "HumanTask", null, new QueryContext());
    Assertions.assertThat(foundList).hasSize(3);
    for (ProcessInstanceDesc pid : foundList) {
        Assertions.assertThat(pid.getProcessName()).isEqualTo("HumanTask");
        Assertions.assertThat(pid.getProcessId()).isEqualTo("org.jboss.qa.bpms.HumanTask");
    }
}
Also used : 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