Search in sources :

Example 36 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testFixedDateStartTimerEvent.

@Deployment
public void testFixedDateStartTimerEvent() throws Exception {
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    processEngineConfiguration.getClock().setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30"));
    waitForJobExecutorToProcessAllJobs(5000L, 25L);
    List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
    assertEquals(1, pi.size());
    assertEquals(0, jobQuery.count());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) SimpleDateFormat(java.text.SimpleDateFormat) Deployment(org.activiti.engine.test.Deployment)

Example 37 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.

the class StartTimerEventTest method testTimerShouldNotBeRemovedWhenUndeployingOldVersion.

// Test for ACT-1533
public void testTimerShouldNotBeRemovedWhenUndeployingOldVersion() throws Exception {
    // Deploy test process
    String processXml = new String(IoUtil.readInputStream(getClass().getResourceAsStream("StartTimerEventTest.testTimerShouldNotBeRemovedWhenUndeployingOldVersion.bpmn20.xml"), ""));
    String firstDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml", new ByteArrayInputStream(processXml.getBytes())).deploy().getId();
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    //we deploy new process version, with some small change
    String processChanged = processXml.replaceAll("beforeChange", "changed");
    String secondDeploymentId = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml", new ByteArrayInputStream(processChanged.getBytes())).deploy().getId();
    assertEquals(1, jobQuery.count());
    // Remove the first deployment
    repositoryService.deleteDeployment(firstDeploymentId, true);
    // The removal of an old version should not affect timer deletion
    // ACT-1533: this was a bug, and the timer was deleted!
    assertEquals(1, jobQuery.count());
    // Cleanup
    cleanDB();
    repositoryService.deleteDeployment(secondDeploymentId, true);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) JobQuery(org.activiti.engine.runtime.JobQuery)

Example 38 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project herd by FINRAOS.

the class ActivitiServiceTest method testGetJobsWithExceptionCountByProcessInstanceId.

@Test
public void testGetJobsWithExceptionCountByProcessInstanceId() {
    String processInstanceId = "processInstanceId";
    JobQuery jobQuery = mock(JobQuery.class);
    when(activitiManagementService.createJobQuery()).thenReturn(jobQuery);
    when(jobQuery.withException()).thenReturn(jobQuery);
    when(jobQuery.processInstanceId(processInstanceId)).thenReturn(jobQuery);
    long expectedResult = 1234l;
    when(jobQuery.count()).thenReturn(expectedResult);
    long actualResult = activitiService.getJobsWithExceptionCountByProcessInstanceId(processInstanceId);
    assertEquals(expectedResult, actualResult);
    InOrder inOrder = inOrder(jobQuery);
    inOrder.verify(jobQuery).withException();
    inOrder.verify(jobQuery).processInstanceId(processInstanceId);
    inOrder.verify(jobQuery).count();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) JobQuery(org.activiti.engine.runtime.JobQuery) Test(org.junit.Test)

Example 39 with JobQuery

use of org.activiti.engine.runtime.JobQuery in project carbon-business-process by wso2.

the class ManagementService method getJobs.

@GET
@Path("/jobs")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DataResponse getJobs() {
    JobQuery query = managementService.createJobQuery();
    Map<String, String> allRequestParams = Utils.populateRequestParams(jobPropertiesList, uriInfo);
    allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
    if (allRequestParams.containsKey("id")) {
        query.jobId(allRequestParams.get("id"));
    }
    if (allRequestParams.containsKey("processInstanceId")) {
        query.processInstanceId(allRequestParams.get("processInstanceId"));
    }
    if (allRequestParams.containsKey("executionId")) {
        query.executionId(allRequestParams.get("executionId"));
    }
    if (allRequestParams.containsKey("processDefinitionId")) {
        query.processDefinitionId(allRequestParams.get("processDefinitionId"));
    }
    if (allRequestParams.containsKey("withRetriesLeft")) {
        if (Boolean.valueOf(allRequestParams.get("withRetriesLeft"))) {
            query.withRetriesLeft();
        }
    }
    if (allRequestParams.containsKey("executable")) {
        if (Boolean.valueOf(allRequestParams.get("executable"))) {
            query.executable();
        }
    }
    if (allRequestParams.containsKey("timersOnly")) {
        if (allRequestParams.containsKey("messagesOnly")) {
            throw new ActivitiIllegalArgumentException("Only one of 'timersOnly' or 'messagesOnly' can be provided.");
        }
        if (Boolean.valueOf(allRequestParams.get("timersOnly"))) {
            query.timers();
        }
    }
    if (allRequestParams.containsKey("messagesOnly")) {
        if (Boolean.valueOf(allRequestParams.get("messagesOnly"))) {
            query.messages();
        }
    }
    if (allRequestParams.containsKey("dueBefore")) {
        query.duedateLowerThan(RequestUtil.getDate(allRequestParams, "dueBefore"));
    }
    if (allRequestParams.containsKey("dueAfter")) {
        query.duedateHigherThan(RequestUtil.getDate(allRequestParams, "dueAfter"));
    }
    if (allRequestParams.containsKey("withException")) {
        if (Boolean.valueOf(allRequestParams.get("withException"))) {
            query.withException();
        }
    }
    if (allRequestParams.containsKey("exceptionMessage")) {
        query.exceptionMessage(allRequestParams.get("exceptionMessage"));
    }
    if (allRequestParams.containsKey("tenantId")) {
        query.jobTenantId(allRequestParams.get("tenantId"));
    }
    if (allRequestParams.containsKey("tenantIdLike")) {
        query.jobTenantIdLike(allRequestParams.get("tenantIdLike"));
    }
    if (allRequestParams.containsKey("withoutTenantId")) {
        if (Boolean.valueOf(allRequestParams.get("withoutTenantId"))) {
            query.jobWithoutTenantId();
        }
    }
    return new JobPaginateList(restResponseFactory, uriInfo).paginateList(allRequestParams, query, "id", properties);
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery)

Aggregations

JobQuery (org.activiti.engine.runtime.JobQuery)39 Deployment (org.activiti.engine.test.Deployment)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)17 Date (java.util.Date)15 Job (org.activiti.engine.runtime.Job)9 Task (org.activiti.engine.task.Task)5 HashMap (java.util.HashMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 Execution (org.activiti.engine.runtime.Execution)2 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 ArrayList (java.util.ArrayList)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1