Search in sources :

Example 36 with ProcessInstanceDesc

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

the class ESignalTest method testSignalProcessInstance.

@Test
public void testSignalProcessInstance() {
    Long pid1 = archive.startProcess(kieJar, SIGNAL_PROCESS_ID);
    Assertions.assertThat(pid1).isNotNull();
    Long pid2 = archive.startProcess(kieJar, SIGNAL_PROCESS_ID);
    Assertions.assertThat(pid2).isNotNull();
    Collection<String> signals = processService.getAvailableSignals(pid1);
    Assertions.assertThat(signals).isNotNull();
    Assertions.assertThat(signals).hasSize(1);
    Assertions.assertThat(signals).contains("MySignal");
    processService.signalProcessInstance(pid1, "MySignal", "Hello World!!");
    ProcessInstanceDesc log1 = runtimeDataService.getProcessInstanceById(pid1);
    Assertions.assertThat(log1).isNotNull();
    Assertions.assertThat(log1.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    ProcessInstanceDesc log2 = runtimeDataService.getProcessInstanceById(pid2);
    Assertions.assertThat(log2).isNotNull();
    Assertions.assertThat(log2.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    processService.signalProcessInstance(pid2, "MySignal", "Hello World!!");
    log2 = runtimeDataService.getProcessInstanceById(pid2);
    Assertions.assertThat(log2).isNotNull();
    Assertions.assertThat(log2.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) Test(org.junit.Test)

Example 37 with ProcessInstanceDesc

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

the class ETaskOperationTest method testStartAndComplete.

@Test
public void testStartAndComplete() {
    Long processInstanceId = archive.startProcess(kieJar, HUMAN_TASK_PROCESS_ID);
    Assertions.assertThat(processInstanceId).isNotNull();
    List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
    Assertions.assertThat(taskIds).isNotNull();
    Assertions.assertThat(taskIds).hasSize(1);
    Long taskId = taskIds.get(0);
    userTaskService.start(taskId, userId);
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getStatus()).isEqualTo(Status.InProgress.toString());
    Map<String, Object> results = new HashMap<String, Object>();
    userTaskService.complete(taskId, userId, results);
    task = runtimeDataService.getTaskById(taskId);
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getStatus()).isEqualTo(Status.Completed.toString());
    ProcessInstanceDesc log = runtimeDataService.getProcessInstanceById(processInstanceId);
    Assertions.assertThat(log).isNotNull();
    Assertions.assertThat(log.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Example 38 with ProcessInstanceDesc

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

the class EStartProcessInstanceTest method testStartScriptTaskProcess.

@Test
public void testStartScriptTaskProcess() {
    long pid = ejb.startProcessSimple(ProcessDefinitions.SCRIPT_TASK);
    ProcessInstanceDesc log = ejb.getProcessInstanceById(pid);
    Assertions.assertThat(log.getProcessId()).isEqualTo(ProcessDefinitions.SCRIPT_TASK);
    Assertions.assertThat(log.getState()).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 39 with ProcessInstanceDesc

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

the class EStartProcessInstanceTest method testStringNumberParams.

@Test
public void testStringNumberParams() {
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("var1", "\"10\"");
    parameters.put("var2", "\"20\"");
    long pid = ejb.startProcess(ProcessDefinitions.SCRIPT_TASK_TWO_VARIABLES, parameters);
    ProcessInstanceDesc piDesc = ejb.getProcessInstanceById(pid);
    Assertions.assertThat(piDesc).isNotNull();
    Assertions.assertThat(piDesc.getProcessId()).isEqualTo(ProcessDefinitions.SCRIPT_TASK_TWO_VARIABLES);
    Assertions.assertThat(piDesc.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 40 with ProcessInstanceDesc

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

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