Search in sources :

Example 1 with STATUS

use of org.kie.api.executor.STATUS 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);
}
Also used : STATUS(org.kie.api.executor.STATUS) CommandContext(org.kie.api.executor.CommandContext) AtomicLong(java.util.concurrent.atomic.AtomicLong) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) Test(org.junit.Test)

Example 2 with STATUS

use of org.kie.api.executor.STATUS in project jbpm by kiegroup.

the class BasicExecutorBaseTest method testProcessContextJobsExecution.

@Test(timeout = 10000)
public void testProcessContextJobsExecution() throws InterruptedException {
    CountDownAsyncJobListener countDownListener = configureListener(1);
    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> 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(0, executedRequests.size());
    countDownListener.waitTillCompleted(5000);
    inErrorRequests = executorService.getInErrorRequests(new QueryContext());
    assertEquals(0, inErrorRequests.size());
    queuedRequests = executorService.getQueuedRequests(new QueryContext());
    assertEquals(1, queuedRequests.size());
    executedRequests = executorService.getCompletedRequests(new QueryContext());
    assertEquals(0, executedRequests.size());
    executorService.cancelRequest(requestId);
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) STATUS(org.kie.api.executor.STATUS) CommandContext(org.kie.api.executor.CommandContext) AtomicLong(java.util.concurrent.atomic.AtomicLong) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) Test(org.junit.Test)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Test (org.junit.Test)2 CommandContext (org.kie.api.executor.CommandContext)2 RequestInfo (org.kie.api.executor.RequestInfo)2 STATUS (org.kie.api.executor.STATUS)2 QueryContext (org.kie.api.runtime.query.QueryContext)2 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)1