use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class ExecutorLogCleanTest method deleteErrorLogsByDate.
@Test
@BZ("1188702")
public void deleteErrorLogsByDate() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(2);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
KieSession ksession = createKSession(ASYNC_DATA_EXEC);
WorkItemManager wim = ksession.getWorkItemManager();
wim.registerWorkItemHandler("async", new AsyncWorkItemHandler(getExecutorService()));
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("command", "org.jbpm.test.jobexec.UserFailingCommand");
ProcessInstance pi = ksession.startProcess(ASYNC_DATA_EXEC_ID, pm);
// Wait for the all retries to fail
countDownListener.waitTillCompleted();
// Assert completion of the job
List<ErrorInfo> errorList = getExecutorService().getAllErrors(new QueryContext());
Assertions.assertThat(errorList).hasSize(2);
// Delete a record
int resultCount = auditService.errorInfoLogDeleteBuilder().date(errorList.get(0).getTime()).build().execute();
Assertions.assertThat(resultCount).isEqualTo(1);
// Assert remaining records
Assertions.assertThat(getExecutorService().getAllErrors(new QueryContext())).hasSize(1);
// Abort running process instance
ksession.abortProcessInstance(pi.getId());
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class AsyncTaskTransactionTest method testJobCommitInAsyncExec.
@Test(timeout = 10000)
public void testJobCommitInAsyncExec() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
KieSession ksession = registerAsyncHandler(createKSession(ASYNC_EXECUTOR_2, ASYNC_DATA_EXECUTOR));
ProcessInstance pi;
UserTransaction ut = getUserTransaction();
try {
ut.begin();
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("_command", USER_COMMAND);
pi = ksession.startProcess(ASYNC_EXECUTOR_2_ID, pm);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
assertProcessInstanceCompleted(pi.getId());
countDownListener.waitTillCompleted();
Assertions.assertThat(getExecutorService().getCompletedRequests(new QueryContext())).hasSize(1);
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class AsyncTaskTransactionTest method testJobRollbackInAsyncExec.
@Test
public void testJobRollbackInAsyncExec() throws Exception {
KieSession ksession = registerAsyncHandler(createKSession(ASYNC_EXECUTOR_2, ASYNC_DATA_EXECUTOR));
long processId;
UserTransaction ut = getUserTransaction();
try {
ut.begin();
Map<String, Object> pm = new HashMap<String, Object>();
pm.put("_command", USER_COMMAND);
ProcessInstance pi = ksession.startProcess(ASYNC_EXECUTOR_2_ID, pm);
processId = pi.getId();
} finally {
ut.rollback();
}
assertProcessInstanceNeverRun(processId);
Assertions.assertThat(getExecutorService().getCompletedRequests(new QueryContext())).hasSize(0);
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class EProcessHistoryTest method testProcessInstanceLogsWithDefinitionId.
@Test
public void testProcessInstanceLogsWithDefinitionId() {
QueryContext queryContext = new QueryContext(0, Integer.MAX_VALUE);
int originalSize = ejb.getProcessInstancesByProcessDefinition(ProcessDefinitions.HUMAN_TASK, queryContext).size();
startProcess(ProcessDefinitions.SCRIPT_TASK, 3);
startProcess(ProcessDefinitions.HUMAN_TASK, 5);
Collection<ProcessInstanceDesc> logs = ejb.getProcessInstancesByProcessDefinition(ProcessDefinitions.HUMAN_TASK, queryContext);
Assertions.assertThat(logs).hasSize(originalSize + 5);
}
use of org.kie.api.runtime.query.QueryContext in project jbpm by kiegroup.
the class EProcessHistoryTest method testAllProcessInstanceLogs.
@Test
public void testAllProcessInstanceLogs() {
QueryContext queryContext = new QueryContext(0, Integer.MAX_VALUE);
List<ProcessInstanceDesc> logs = ejb.getProcessInstances(queryContext);
int originalSize = logs.size();
startProcess(ProcessDefinitions.SCRIPT_TASK, 4);
startProcess(ProcessDefinitions.HUMAN_TASK, 3);
logs = ejb.getProcessInstances(queryContext);
Assertions.assertThat(logs).hasSize(originalSize + 4 + 3);
}
Aggregations