use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method cancelRequestWithSearchByCommandTest.
@Test(timeout = 10000)
public void cancelRequestWithSearchByCommandTest() throws InterruptedException {
CommandContext ctxCMD = new CommandContext();
String businessKey = UUID.randomUUID().toString();
ctxCMD.setData("businessKey", businessKey);
Date futureDate = new Date(System.currentTimeMillis() + EXTRA_TIME);
Long requestId = executorService.scheduleRequest("org.jbpm.executor.test.CustomCommand", futureDate, ctxCMD);
List<RequestInfo> requests = executorService.getRequestsByCommand("org.jbpm.executor.test.CustomCommand", new QueryContext());
assertNotNull(requests);
assertEquals(1, requests.size());
assertEquals(requestId, requests.get(0).getId());
// cancel the task immediately
executorService.cancelRequest(requestId);
List<RequestInfo> cancelledRequests = executorService.getCancelledRequests(new QueryContext());
assertEquals(1, cancelledRequests.size());
}
use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method defaultRequestRetryTest.
@Test(timeout = 10000)
public void defaultRequestRetryTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(4);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
RequestInfo failedJob = inErrorRequests.get(0);
assertEquals(4, failedJob.getExecutions());
List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
logger.info("Errors: {}", errors);
// Three retries means 4 executions in total 1(regular) + 3(retries)
assertEquals(4, errors.size());
}
use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method cleanupLogExecutionTest.
@Test(timeout = 10000)
public void cleanupLogExecutionTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(3);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
Long requestId = executorService.scheduleRequest("org.jbpm.executor.commands.ReoccurringPrintOutCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(1, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(3, executedRequests.size());
executorService.cancelRequest(requestId + 3);
List<RequestInfo> canceled = executorService.getCancelledRequests(new QueryContext());
ExecutorJPAAuditService auditService = new ExecutorJPAAuditService(emf);
int resultCount = auditService.requestInfoLogDeleteBuilder().date(canceled.get(0).getTime()).status(STATUS.ERROR).build().execute();
assertEquals(0, resultCount);
resultCount = auditService.errorInfoLogDeleteBuilder().date(canceled.get(0).getTime()).build().execute();
assertEquals(0, resultCount);
ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
ctxCMD.setData("SingleRun", "true");
ctxCMD.setData("EmfName", "org.jbpm.executor");
ctxCMD.setData("SkipProcessLog", "true");
ctxCMD.setData("SkipTaskLog", "true");
executorService.scheduleRequest("org.jbpm.executor.commands.LogCleanupCommand", ctxCMD);
countDownListener.reset(1);
countDownListener.waitTillCompleted();
inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
}
use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method clearAllRequestsTest.
@Test(timeout = 10000)
public void clearAllRequestsTest() throws InterruptedException {
CommandContext ctxCMD = new CommandContext();
String businessKey = UUID.randomUUID().toString();
ctxCMD.setData("businessKey", businessKey);
Date futureDate = new Date(System.currentTimeMillis() + EXTRA_TIME);
// Testing clearing of active request.
Long requestId = executorService.scheduleRequest("org.jbpm.executor.test.CustomCommand", futureDate, ctxCMD);
List<RequestInfo> allRequests = executorService.getAllRequests(new QueryContext());
assertEquals(1, allRequests.size());
executorService.clearAllRequests();
allRequests = executorService.getAllRequests(new QueryContext());
assertEquals(0, allRequests.size());
// Testing clearing of cancelled request.
requestId = executorService.scheduleRequest("org.jbpm.executor.test.CustomCommand", futureDate, ctxCMD);
allRequests = executorService.getAllRequests(new QueryContext());
assertEquals(1, allRequests.size());
executorService.cancelRequest(requestId);
executorService.clearAllRequests();
allRequests = executorService.getAllRequests(new QueryContext());
assertEquals(0, allRequests.size());
}
use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method testJobsQueryWithStatus.
@Test(timeout = 10000)
public void testJobsQueryWithStatus() throws InterruptedException {
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", "low priority");
ctxCMD.setData("deploymentId", "not-deployed-here");
ctxCMD.setData("processInstanceId", 2L);
Long requestId = executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
List<STATUS> statuses = Arrays.asList(STATUS.QUEUED);
List<RequestInfo> byDeploymentRequests = executorService.getRequestsByDeployment("not-deployed-here", statuses, new QueryContext());
assertEquals(1, byDeploymentRequests.size());
List<RequestInfo> byProcessInstanceRequests = executorService.getRequestsByProcessInstance(2L, statuses, new QueryContext());
assertEquals(1, byProcessInstanceRequests.size());
List<RequestInfo> byKeyRequests = executorService.getRequestsByBusinessKey("low priority", statuses, new QueryContext());
assertEquals(1, byKeyRequests.size());
List<RequestInfo> byCommandRequests = executorService.getRequestsByCommand("org.jbpm.executor.commands.PrintOutCommand", statuses, new QueryContext());
assertEquals(1, byCommandRequests.size());
statuses = Arrays.asList(STATUS.DONE);
byDeploymentRequests = executorService.getRequestsByDeployment("not-deployed-here", statuses, new QueryContext());
assertEquals(0, byDeploymentRequests.size());
byProcessInstanceRequests = executorService.getRequestsByProcessInstance(2L, statuses, new QueryContext());
assertEquals(0, byProcessInstanceRequests.size());
byKeyRequests = executorService.getRequestsByBusinessKey("low priority", statuses, new QueryContext());
assertEquals(0, byKeyRequests.size());
byCommandRequests = executorService.getRequestsByCommand("org.jbpm.executor.commands.PrintOutCommand", statuses, new QueryContext());
assertEquals(0, byCommandRequests.size());
executorService.cancelRequest(requestId);
}
Aggregations