use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.
the class LogCleanupCommandTest method deleteAllLogsOlderThanTomorrowDifferentProcess.
@Test(timeout = 10000)
public void deleteAllLogsOlderThanTomorrowDifferentProcess() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
deleteAllLogsOlderThan(getTomorrow(), HELLO_WORLD_ID, ANOTHER_PROCESS, countDownListener);
Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isPositive();
Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
}
use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.
the class AsyncTaskTest method testTaskComplete.
@Test(timeout = 10000)
@BZ("1121027")
public void testTaskComplete() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Process async", 1);
CountDownAsyncJobListener countDownJobListener = new CountDownAsyncJobListener(1);
try {
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownJobListener);
addProcessEventListener(countDownListener);
KieSession ksession = createKSession(ASYNC_DATA_EXECUTOR);
WorkItemManager wim = ksession.getWorkItemManager();
wim.registerWorkItemHandler("async", new AsyncWorkItemHandler(getExecutorService()));
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("command", USER_COMMAND);
ProcessInstance pi = ksession.startProcess(ASYNC_DATA_EXECUTOR_ID, pm);
assertNodeTriggered(pi.getId(), "StartProcess", "Set user info", "Process async");
// Wait for the job to complete
countDownListener.waitTillCompleted();
ProcessInstance processInstance = ksession.getProcessInstance(pi.getId());
assertNull(processInstance);
assertNodeTriggered(pi.getId(), "Output", "EndProcess");
countDownJobListener.waitTillCompleted();
Assertions.assertThat(getExecutorService().getCompletedRequests(new QueryContext())).hasSize(1);
assertProcessInstanceCompleted(pi.getId());
} finally {
((ExecutorServiceImpl) getExecutorService()).removeAsyncJobListener(countDownJobListener);
}
}
use of org.jbpm.test.listener.CountDownAsyncJobListener in project jbpm by kiegroup.
the class AsyncTaskTest method testTaskFail.
@Test(timeout = 10000)
public void testTaskFail() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(4);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
KieSession ksession = createKSession(ASYNC_DATA_EXECUTOR);
WorkItemManager wim = ksession.getWorkItemManager();
wim.registerWorkItemHandler("async", new AsyncWorkItemHandler(getExecutorService()));
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("command", USER_FAILING_COMMAND);
ProcessInstance pi = ksession.startProcess(ASYNC_DATA_EXECUTOR_ID, pm);
assertNodeTriggered(pi.getId(), "StartProcess", "Set user info", "Process async");
assertNodeNotTriggered(pi.getId(), "Output");
// Wait for the 4 retries to fail
countDownListener.waitTillCompleted();
ProcessInstance processInstance = ksession.getProcessInstance(pi.getId());
assertNotNull(processInstance);
assertNodeNotTriggered(pi.getId(), "Output");
Assertions.assertThat(getExecutorService().getInErrorRequests(new QueryContext())).hasSize(1);
Assertions.assertThat(getExecutorService().getInErrorRequests(new QueryContext()).get(0).getErrorInfo()).hasSize(4);
Assertions.assertThat(getExecutorService().getInErrorRequests(new QueryContext()).get(0).getErrorInfo().get(0).getMessage()).isEqualTo("Internal Error");
assertProcessInstanceActive(pi.getId());
ksession.abortProcessInstance(pi.getId());
assertProcessInstanceAborted(pi.getId());
}
Aggregations