use of org.jbpm.executor.test.CountDownAsyncJobListener in project jbpm by kiegroup.
the class BasicExecutorBaseTest method addAnotherCallbackTest.
@Test(timeout = 10000)
public void addAnotherCallbackTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(1);
CommandContext commandContext = new CommandContext();
commandContext.setData("businessKey", UUID.randomUUID().toString());
cachedEntities.put((String) commandContext.getData("businessKey"), new AtomicLong(1));
commandContext.setData("callbacks", "org.jbpm.executor.SimpleIncrementCallback");
executorService.scheduleRequest("org.jbpm.executor.test.AddAnotherCallbackCommand", commandContext);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
assertEquals(3, ((AtomicLong) cachedEntities.get((String) commandContext.getData("businessKey"))).longValue());
}
use of org.jbpm.executor.test.CountDownAsyncJobListener in project jbpm by kiegroup.
the class BasicExecutorBaseTest method testUpdateRequestDataFromErrorState.
@Test(timeout = 10000)
public void testUpdateRequestDataFromErrorState() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(1);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
ctxCMD.setData("retries", 0);
Long requestId = executorService.scheduleRequest("org.jbpm.executor.test.MissingDataCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
Map<String, Object> fixedData = new HashMap<>();
fixedData.put("amount", 200);
executorService.updateRequestData(requestId, fixedData);
countDownListener.reset(1);
((RequeueAware) executorService).requeueById(requestId);
countDownListener.waitTillCompleted();
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
}
use of org.jbpm.executor.test.CountDownAsyncJobListener in project jbpm by kiegroup.
the class ReconfiguredExecutorTest method simpleExcecutionTest.
@Test
public void simpleExcecutionTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(1);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
}
use of org.jbpm.executor.test.CountDownAsyncJobListener in project jbpm by kiegroup.
the class JmsAvaiableJobExecutorTest method testAsyncAuditProducerPrioritizedJobs.
@Test
public void testAsyncAuditProducerPrioritizedJobs() throws Exception {
CountDownAsyncJobListener countDownListener = configureListener(2);
final List<String> executedJobs = new ArrayList<String>();
((ExecutorServiceImpl) executorService).addAsyncJobListener(new AsynchronousJobListener() {
@Override
public void beforeJobScheduled(AsynchronousJobEvent event) {
}
@Override
public void beforeJobExecuted(AsynchronousJobEvent event) {
}
@Override
public void beforeJobCancelled(AsynchronousJobEvent event) {
}
@Override
public void afterJobScheduled(AsynchronousJobEvent event) {
}
@Override
public void afterJobExecuted(AsynchronousJobEvent event) {
executedJobs.add(event.getJob().getKey());
}
@Override
public void afterJobCancelled(AsynchronousJobEvent event) {
}
});
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", "low priority");
ctxCMD.setData("priority", 2);
CommandContext ctxCMD2 = new CommandContext();
ctxCMD2.setData("businessKey", "high priority");
ctxCMD2.setData("priority", 8);
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD2);
ut.commit();
MessageReceiver receiver = new MessageReceiver();
receiver.receiveAndProcess(queue, countDownListener);
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(2, executedRequests.size());
assertEquals(2, executedJobs.size());
assertEquals("high priority", executedJobs.get(0));
assertEquals("low priority", executedJobs.get(1));
}
use of org.jbpm.executor.test.CountDownAsyncJobListener in project jbpm by kiegroup.
the class JmsAvaiableJobExecutorTest method testAsyncAuditProducer.
@Test
public void testAsyncAuditProducer() throws Exception {
CountDownAsyncJobListener countDownListener = configureListener(1);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
ut.commit();
MessageReceiver receiver = new MessageReceiver();
receiver.receiveAndProcess(queue, countDownListener);
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
}
Aggregations