private void testStartProcessResponseHandler(ResponseHandler responseHandler) throws Exception { List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isEmpty(); // change response handler for processClient others are not affected processClient.setResponseHandler(responseHandler); Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); // since we use fire and forget there will always be null response assertThat(processInstanceId).isNull(); KieServerSynchronization.waitForProcessInstanceStart(queryClient, CONTAINER_ID); // Process should be started completely async - fire and forget. processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).hasSize(1); ProcessInstance pi = processInstances.get(0); assertThat(pi.getState()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE); }
private void testGetTaskResponseHandler(ResponseHandler responseHandler) throws Exception { List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isEmpty(); Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); assertThat(processInstanceId).isNotNull(); KieServerSynchronization.waitForProcessInstanceStart(queryClient, CONTAINER_ID); // Process should be started completely async - fire and forget. processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isNotNull().hasSize(1); ProcessInstance pi = processInstances.get(0); assertThat(pi.getState()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE); // change response handler for taskClient others are not affected taskClient.setResponseHandler(responseHandler); List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertThat(tasks).isNull(); }
private void testGetProcessInstancesResponseHandler(ResponseHandler responseHandler) throws Exception { List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isEmpty(); Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); assertThat(processInstanceId).isNotNull(); KieServerSynchronization.waitForProcessInstanceStart(queryClient, CONTAINER_ID); // change response handler for queryClient others are not affected queryClient.setResponseHandler(responseHandler); // Process should be started completely async - fire and forget. processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isNull(); // set it back for the sake of verification queryClient.setResponseHandler(new RequestReplyResponseHandler()); // Process should be started completely async - fire and forget. processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isNotNull().hasSize(1); ProcessInstance pi = processInstances.get(0); assertThat(pi.getState()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE); }
@Test public void testTransactionRollback() throws Exception { transaction.begin(); Long processInstanceId = transactionalProcessClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); assertThat(processInstanceId).isNull(); transaction.rollback(); List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 10); assertThat(processInstances).isNotNull().isEmpty(); }
@Test public void testGetProcessInstances() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("stringData", "waiting for signal"); parameters.put("personData", createPersonInstance(USER_JOHN)); List<Long> processInstanceIds = createProcessInstances(parameters); try { List<ProcessInstance> instances = queryClient.findProcessInstances(0, 10); assertNotNull(instances); assertEquals(5, instances.size()); List<Long> found = collectInstances(instances); assertEquals(processInstanceIds, found); instances = queryClient.findProcessInstances(0, 3); assertNotNull(instances); assertEquals(3, instances.size()); instances = queryClient.findProcessInstances(1, 3); assertNotNull(instances); assertEquals(2, instances.size()); } finally { abortProcessInstances(processInstanceIds); } }
List<ProcessInstance> instances = queryClient.findProcessInstances(0, 3, SORT_BY_PROCESS_ID, true); assertNotNull(instances); assertEquals(3, instances.size()); instances = queryClient.findProcessInstances(1, 3, SORT_BY_PROCESS_ID, true); assertNotNull(instances); assertEquals(2, instances.size()); instances = queryClient.findProcessInstances(0, 10, SORT_BY_PROCESS_ID, false); assertNotNull(instances); assertEquals(5, instances.size());
List<ProcessInstance> instances = queryClient.findProcessInstances(0, 3, SORT_BY_PROCESS_ID, true); assertNotNull(instances); assertEquals(3, instances.size()); instances = queryClient.findProcessInstances(1, 3, SORT_BY_PROCESS_ID, true); assertNotNull(instances); assertEquals(2, instances.size()); instances = queryClient.findProcessInstances(0, 10, SORT_BY_PROCESS_ID, false); assertNotNull(instances); assertEquals(5, instances.size());
private void testStartAndCompleteTask(ResponseHandler responseHandler) throws Exception { Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK); assertThat(processInstanceId).isNotNull(); List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 100); assertThat(processInstances).isNotNull().hasSize(1); assertThat(processInstances.get(0)).isNotNull(); assertThat(processInstances.get(0).getState()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE); List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertThat(tasks).hasSize(1); Long taskId = tasks.get(0).getId(); taskClient.setResponseHandler(responseHandler); taskClient.startTask(CONTAINER_ID, taskId, USER_YODA); taskClient.setResponseHandler(new RequestReplyResponseHandler()); KieServerSynchronization.waitForTaskStatus(taskClient, taskId, Status.InProgress.name()); taskClient.setResponseHandler(responseHandler); taskClient.completeTask(CONTAINER_ID, taskId, USER_YODA, new HashMap<String, Object>()); taskClient.setResponseHandler(new RequestReplyResponseHandler()); KieServerSynchronization.waitForTaskStatus(taskClient, taskId, Status.Completed.name()); tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); assertThat(tasks).hasSize(1); taskId = tasks.get(0).getId(); taskClient.setResponseHandler(responseHandler); taskClient.startTask(CONTAINER_ID, taskId, USER_YODA); taskClient.setResponseHandler(new RequestReplyResponseHandler()); KieServerSynchronization.waitForTaskStatus(taskClient, taskId, Status.InProgress.name()); taskClient.setResponseHandler(responseHandler); taskClient.completeTask(CONTAINER_ID, taskId, USER_YODA, new HashMap<String, Object>()); KieServerSynchronization.waitForProcessInstanceToFinish(processClient, CONTAINER_ID, processInstanceId); }
List<ProcessInstance> processInstances = queryClient.findProcessInstances(0, 100); assertEquals(1, processInstances.size());