Search in sources :

Example 46 with ProcessInstanceDesc

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

the class EProcessHistoryTest method testAllProcessInstanceLogs.

@Test
public void testAllProcessInstanceLogs() {
    QueryContext queryContext = new QueryContext(0, Integer.MAX_VALUE);
    List<ProcessInstanceDesc> logs = ejb.getProcessInstances(queryContext);
    int originalSize = logs.size();
    startProcess(ProcessDefinitions.SCRIPT_TASK, 4);
    startProcess(ProcessDefinitions.HUMAN_TASK, 3);
    logs = ejb.getProcessInstances(queryContext);
    Assertions.assertThat(logs).hasSize(originalSize + 4 + 3);
}
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 47 with ProcessInstanceDesc

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

the class EEndProcessInstanceTest method testAbortProcessInstance.

@Test()
public void testAbortProcessInstance() {
    long pid = ejb.startProcessSimple(ProcessDefinitions.SIGNAL);
    ejb.abortProcessInstance(pid);
    ProcessInstanceDesc log = ejb.getProcessInstanceById(pid);
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState().intValue()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 48 with ProcessInstanceDesc

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

Example 49 with ProcessInstanceDesc

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

the class ESignalProcessInstanceTest method testSignalProcessInstance.

@Test()
public void testSignalProcessInstance() {
    long processInstanceId1 = ejb.startProcessSimple(ProcessDefinitions.SIGNAL);
    long processInstanceId2 = ejb.startProcessSimple(ProcessDefinitions.SIGNAL);
    List<String> signals = ejb.getAvailableSignals(processInstanceId1);
    Assertions.assertThat(signals).isNotNull();
    Assertions.assertThat(signals.size()).isEqualTo(1);
    Assertions.assertThat(signals.get(0)).isEqualTo("MySignal");
    ejb.signalProcessInstance(processInstanceId1, "MySignal", "Hello World!!");
    ProcessInstanceDesc log = ejb.getProcessInstanceById(processInstanceId1);
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState().intValue()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    log = ejb.getProcessInstanceById(processInstanceId2);
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState().intValue()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    ejb.signalProcessInstance(processInstanceId2, "MySignal", "Hello World!!");
    log = ejb.getProcessInstanceById(processInstanceId2);
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState().intValue()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 50 with ProcessInstanceDesc

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

the class RuntimeDataServiceImplTest method testGetTasksAssignedAsPotentialOwnerSortedByAlias.

@Test
public void testGetTasksAssignedAsPotentialOwnerSortedByAlias() {
    List<Long> processInstanceIds = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
        processInstanceIds.add(processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"));
    }
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    QueryFilter ctx = new QueryFilter(0, 5, "Status", true);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, ctx);
    assertNotNull(tasks);
    assertEquals(5, tasks.size());
    TaskSummary userTask = tasks.get(0);
    assertNotNull(userTask);
    assertEquals("Write a Document", userTask.getName());
    Collection<ProcessInstanceDesc> activeProcesses = runtimeDataService.getProcessInstances(new QueryContext(0, 20));
    for (ProcessInstanceDesc pi : activeProcesses) {
        processService.abortProcessInstance(pi.getId());
    }
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) 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