Search in sources :

Example 66 with QueryContext

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());
}
Also used : ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) HashMap(java.util.HashMap) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) AsyncWorkItemHandler(org.jbpm.executor.impl.wih.AsyncWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 67 with QueryContext

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);
}
Also used : UserTransaction(javax.transaction.UserTransaction) CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 68 with QueryContext

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);
}
Also used : UserTransaction(javax.transaction.UserTransaction) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 69 with QueryContext

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);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 70 with QueryContext

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);
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Aggregations

QueryContext (org.kie.api.runtime.query.QueryContext)315 Test (org.junit.Test)299 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)131 HashMap (java.util.HashMap)115 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)109 ArrayList (java.util.ArrayList)99 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)67 RequestInfo (org.kie.api.executor.RequestInfo)53 TaskSummary (org.kie.api.task.model.TaskSummary)53 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)51 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)49 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)45 CommandContext (org.kie.api.executor.CommandContext)39 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)37 UserImpl (org.jbpm.services.task.impl.model.UserImpl)37 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)36 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)34 QueryFilter (org.kie.internal.query.QueryFilter)30 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)29 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)29