use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testCallActivityProcess.
@Test
public void testCallActivityProcess() {
Map<String, Object> parameters = new HashMap<String, Object>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_CALL_EVALUATION, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
// Process instance is running and is active.
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
taskClient.completeAutoProgress(CONTAINER_ID, tasks.get(0).getId(), USER_YODA, null);
List<ProcessInstance> instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, 0, 10);
assertEquals(1, instances.size());
ProcessInstance childInstance = instances.get(0);
assertNotNull(childInstance);
assertEquals(PROCESS_ID_EVALUATION, childInstance.getProcessId());
assertEquals(processInstanceId, childInstance.getParentId());
List<NodeInstance> activeNodes = queryClient.findActiveNodeInstances(processInstanceId, 0, 10);
assertEquals(1, activeNodes.size());
NodeInstance active = activeNodes.get(0);
assertEquals("Call Evaluation", active.getName());
assertEquals("SubProcessNode", active.getNodeType());
assertEquals(childInstance.getId(), active.getReferenceId());
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
// Process instance is now aborted.
processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED, processInstance.getState().intValue());
processInstance = processClient.getProcessInstance(CONTAINER_ID, childInstance.getId());
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED, processInstance.getState().intValue());
// no more active instances
instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, 0, 10);
assertEquals(0, instances.size());
instances = processClient.findProcessInstancesByParent(CONTAINER_ID, processInstanceId, Arrays.asList(3), 0, 10);
assertEquals(1, instances.size());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testProcessInstanceWithTimer.
@Test(timeout = 60 * 1000)
public void testProcessInstanceWithTimer() throws Exception {
Map<String, Object> parameters = new HashMap<>();
parameters.put("timer", "1s");
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_TIMER, parameters);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
try {
KieServerSynchronization.waitForProcessInstanceToFinish(processClient, CONTAINER_ID, processInstanceId);
ProcessInstance pi = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(pi);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testAbortExistingProcess.
@Test()
public void testAbortExistingProcess() {
Map<String, Object> parameters = new HashMap<String, Object>();
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, parameters);
try {
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
// Process instance is running and is active.
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE, processInstance.getState().intValue());
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
// Process instance is now aborted.
processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_ABORTED, processInstance.getState().intValue());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testSignalContainer.
@Test
@Category({ UnstableOnJenkinsPrBuilder.class })
public void testSignalContainer() {
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_SIGNAL_PROCESS);
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
try {
checkAvailableSignals(CONTAINER_ID, processInstanceId);
Object person = createPersonInstance(USER_JOHN);
processClient.signal(CONTAINER_ID, "Signal1", person);
processClient.signal(CONTAINER_ID, "Signal2", "My custom string event");
ProcessInstance pi = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(pi);
assertEquals(STATE_COMPLETED, pi.getState().intValue());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessUserTaskServicesSecurityIntegrationTest method testNonAllowedUserForStartingProcessCanCompleteTask.
@Test
public void testNonAllowedUserForStartingProcessCanCompleteTask() throws Exception {
try {
Long processInstanceId = startProcessAsAdministrator(PROCESS_ID_USERTASK_SECURED);
changeUser(USER_YODA);
List<TaskSummary> taskList = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertThat(taskList).isNotNull().hasSize(1);
Long taskId = taskList.get(0).getId();
taskClient.startTask(CONTAINER_ID_SECURED, taskId, USER_YODA);
taskClient.completeAutoProgress(CONTAINER_ID_SECURED, taskId, USER_YODA, new HashMap<String, Object>());
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_SECURED, processInstanceId);
assertNotNull(processInstance);
assertEquals(STATE_COMPLETED, processInstance.getState().intValue());
} finally {
changeUser(TestConfig.getUsername());
}
}
Aggregations