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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations