Search in sources :

Example 41 with ProcessInstanceDesc

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

the class ETaskOperationTest method testExecuteTaskOpStartAndComplete.

@Test()
public void testExecuteTaskOpStartAndComplete() {
    ProcessInstance pi = startHumanTaskProcess(userId, userId + "'s task 1");
    Long taskId = ejb.getTasksByProcessInstanceId(pi.getId()).get(0);
    ejb.start(taskId, userId);
    Task task = ejb.getTask(taskId);
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getTaskData().getStatus()).isEqualTo(Status.InProgress);
    Map<String, Object> params = new HashMap<>();
    params.put("userId", userId);
    ejb.complete(taskId, userId, params);
    ProcessInstanceDesc log = ejb.getProcessInstanceById(pi.getId());
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : Task(org.kie.api.task.model.Task) HashMap(java.util.HashMap) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 42 with ProcessInstanceDesc

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

the class ETaskOperationTest method testCompleteWorkItem.

/**
 * This test must use another user because the task will remain in the database
 * interfering with other tests. The task will not be deleted because the work item
 * is accessed directly.
 */
@Test()
public void testCompleteWorkItem() {
    ProcessInstance pi = startHumanTaskProcess("root", "Root's task 1");
    Long taskId = ejb.getTasksByProcessInstanceId(pi.getId()).get(0);
    Task task = ejb.getTask(taskId);
    Assertions.assertThat(task).isNotNull();
    ejb.completeWorkItem(task.getTaskData().getWorkItemId());
    ProcessInstanceDesc log = ejb.getProcessInstanceById(pi.getId());
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : Task(org.kie.api.task.model.Task) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 43 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc 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 44 with ProcessInstanceDesc

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

the class EProcessHistoryTest method testProcessInstanceLogsWithDefinitionId.

@Test
public void testProcessInstanceLogsWithDefinitionId() {
    QueryContext queryContext = new QueryContext(0, Integer.MAX_VALUE);
    int originalSize = ejb.getProcessInstancesByProcessDefinition(ProcessDefinitions.HUMAN_TASK, queryContext).size();
    startProcess(ProcessDefinitions.SCRIPT_TASK, 3);
    startProcess(ProcessDefinitions.HUMAN_TASK, 5);
    Collection<ProcessInstanceDesc> logs = ejb.getProcessInstancesByProcessDefinition(ProcessDefinitions.HUMAN_TASK, queryContext);
    Assertions.assertThat(logs).hasSize(originalSize + 5);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 45 with ProcessInstanceDesc

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

the class EProcessHistoryTest method testProcessInstanceLogWithInstanceId.

@Test
public void testProcessInstanceLogWithInstanceId() {
    startProcess(ProcessDefinitions.HUMAN_TASK);
    long pid2 = startProcess(ProcessDefinitions.SCRIPT_TASK);
    ProcessInstanceDesc log = ejb.getProcessInstanceById(pid2);
    Assertions.assertThat(log.getId()).isEqualTo(pid2);
    Assertions.assertThat(log.getProcessId()).isEqualTo(ProcessDefinitions.SCRIPT_TASK);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Aggregations

ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)198 Test (org.junit.Test)147 QueryContext (org.kie.api.runtime.query.QueryContext)123 ArrayList (java.util.ArrayList)75 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)57 HashMap (java.util.HashMap)32 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)25 TaskSummary (org.kie.api.task.model.TaskSummary)25 QueryFilter (org.kie.internal.query.QueryFilter)23 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)17 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)16 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)15 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)12 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)12 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 CorrelationKey (org.kie.internal.process.CorrelationKey)11 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)9 List (java.util.List)7