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());
}
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);
}
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();
}
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);
}
Aggregations