use of org.kie.server.api.model.instance.RequestInfoInstance in project droolsjbpm-integration by kiegroup.
the class ProcessServiceIntegrationTest method testStartProcessInstanceWithAsyncNodes.
@Test(timeout = 60 * 1000)
public void testStartProcessInstanceWithAsyncNodes() throws Exception {
List<String> status = new ArrayList<String>();
status.add(STATUS.QUEUED.toString());
status.add(STATUS.RUNNING.toString());
status.add(STATUS.DONE.toString());
int originalJobCount = jobServicesClient.getRequestsByStatus(status, 0, 1000).size();
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_ASYNC_SCRIPT);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
try {
// async node is executed as a job
List<RequestInfoInstance> jobs = jobServicesClient.getRequestsByStatus(status, 0, 1000);
assertNotNull(jobs);
assertEquals(originalJobCount + 1, jobs.size());
// wait for process instance to be completed
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.RequestInfoInstance in project droolsjbpm-integration by kiegroup.
the class JobServiceIntegrationTest method testScheduleSearchByStatusAndCancelJob.
@Test
public void testScheduleSearchByStatusAndCancelJob() {
int currentNumberOfCancelled = jobServicesClient.getRequestsByStatus(Collections.singletonList(STATUS.CANCELLED.toString()), 0, 100).size();
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DATE, 1);
JobRequestInstance jobRequestInstance = createJobRequestInstance();
jobRequestInstance.setScheduledDate(tomorrow.getTime());
Long jobId = jobServicesClient.scheduleRequest(jobRequestInstance);
assertNotNull(jobId);
assertTrue(jobId.longValue() > 0);
List<String> status = new ArrayList<String>();
status.add(STATUS.QUEUED.toString());
List<RequestInfoInstance> result = jobServicesClient.getRequestsByStatus(status, 0, 100);
assertNotNull(result);
assertEquals(1, result.size());
RequestInfoInstance jobRequest = result.get(0);
RequestInfoInstance expected = createExpectedRequestInfoInstance(jobId, STATUS.QUEUED);
assertRequestInfoInstance(expected, jobRequest);
assertNotNull(jobRequest.getScheduledDate());
jobServicesClient.cancelRequest(jobId);
result = jobServicesClient.getRequestsByStatus(status, 0, 100);
assertNotNull(result);
assertEquals(0, result.size());
// clear status to search only for canceled
status.clear();
status.add(STATUS.CANCELLED.toString());
result = jobServicesClient.getRequestsByStatus(status, 0, 100);
assertNotNull(result);
assertEquals(1 + currentNumberOfCancelled, result.size());
}
use of org.kie.server.api.model.instance.RequestInfoInstance in project droolsjbpm-integration by kiegroup.
the class JobServiceIntegrationTest method runProcessAutoAckErrorCommand.
private void runProcessAutoAckErrorCommand() throws Exception {
Map<String, Object> data = new HashMap<>();
data.put("SingleRun", "true");
data.put("EmfName", "org.jbpm.domain");
JobRequestInstance jobRequestInstance = new JobRequestInstance();
jobRequestInstance.setCommand(PROCESS_AUTO_ACK_ERROR_COMMAND);
jobRequestInstance.setData(data);
Long jobId = jobServicesClient.scheduleRequest(jobRequestInstance);
assertNotNull(jobId);
RequestInfoInstance jobRequest = jobServicesClient.getRequestById(jobId, false, false);
assertNotNull(jobRequest);
KieServerSynchronization.waitForJobToFinish(jobServicesClient, jobId);
}
use of org.kie.server.api.model.instance.RequestInfoInstance in project droolsjbpm-integration by kiegroup.
the class JobServiceIntegrationTest method testScheduleViewAndCancelJob.
@Test
public void testScheduleViewAndCancelJob() {
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DATE, 1);
JobRequestInstance jobRequestInstance = createJobRequestInstance();
jobRequestInstance.setScheduledDate(tomorrow.getTime());
Long jobId = jobServicesClient.scheduleRequest(jobRequestInstance);
assertNotNull(jobId);
assertTrue(jobId.longValue() > 0);
RequestInfoInstance jobRequest = jobServicesClient.getRequestById(jobId, false, false);
RequestInfoInstance expected = createExpectedRequestInfoInstance(jobId, STATUS.QUEUED);
assertRequestInfoInstance(expected, jobRequest);
assertNotNull(jobRequest.getScheduledDate());
jobServicesClient.cancelRequest(jobId);
jobRequest = jobServicesClient.getRequestById(jobId, false, false);
expected.setStatus(STATUS.CANCELLED.toString());
assertRequestInfoInstance(expected, jobRequest);
}
use of org.kie.server.api.model.instance.RequestInfoInstance in project droolsjbpm-integration by kiegroup.
the class JobServiceIntegrationTest method testScheduleAndRunJobWithoutData.
@Test
public void testScheduleAndRunJobWithoutData() throws Exception {
JobRequestInstance jobRequestInstance = new JobRequestInstance();
jobRequestInstance.setCommand(PRINT_OUT_COMMAND);
Long jobId = jobServicesClient.scheduleRequest(jobRequestInstance);
assertNotNull(jobId);
assertTrue(jobId.longValue() > 0);
RequestInfoInstance jobRequest = jobServicesClient.getRequestById(jobId, false, false);
assertNotNull(jobRequest);
assertEquals(jobId, jobRequest.getId());
assertThat(jobRequest.getStatus(), anyOf(equalTo(STATUS.QUEUED.toString()), equalTo(STATUS.RUNNING.toString()), equalTo(STATUS.DONE.toString())));
assertEquals(PRINT_OUT_COMMAND, jobRequest.getCommandName());
KieServerSynchronization.waitForJobToFinish(jobServicesClient, jobId);
jobRequest = jobServicesClient.getRequestById(jobId, false, false);
assertNotNull(jobRequest);
assertEquals(jobId, jobRequest.getId());
assertEquals(STATUS.DONE.toString(), jobRequest.getStatus());
assertEquals(PRINT_OUT_COMMAND, jobRequest.getCommandName());
}
Aggregations