本文整理汇总了Java中org.activiti.engine.runtime.JobQuery类的典型用法代码示例。如果您正苦于以下问题:Java JobQuery类的具体用法?Java JobQuery怎么用?Java JobQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobQuery类属于org.activiti.engine.runtime包,在下文中一共展示了JobQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetJobsWithExceptionByProcessInstanceId
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Test
public void testGetJobsWithExceptionByProcessInstanceId()
{
String processInstanceId = "processInstanceId";
JobQuery jobQuery = mock(JobQuery.class);
when(activitiManagementService.createJobQuery()).thenReturn(jobQuery);
when(jobQuery.withException()).thenReturn(jobQuery);
when(jobQuery.processInstanceId(processInstanceId)).thenReturn(jobQuery);
List<Job> expectedJobs = new ArrayList<>();
when(jobQuery.list()).thenReturn(expectedJobs);
List<Job> actualJobs = activitiService.getJobsWithExceptionByProcessInstanceId(processInstanceId);
assertSame(expectedJobs, actualJobs);
InOrder inOrder = inOrder(jobQuery);
inOrder.verify(jobQuery).withException();
inOrder.verify(jobQuery).processInstanceId(processInstanceId);
inOrder.verify(jobQuery).list();
inOrder.verifyNoMoreInteractions();
}
示例2: testGetJobsWithExceptionCountByProcessInstanceId
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@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();
}
示例3: testQueryByDuedateHigherThenOrEqual
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
public void testQueryByDuedateHigherThenOrEqual() {
JobQuery query = managementService.createJobQuery().duedateHigherThenOrEquals(testStartTime);
verifyQueryResults(query, 3);
query = managementService.createJobQuery().duedateHigherThenOrEquals(timerOneFireTime);
verifyQueryResults(query, 3);
query = managementService.createJobQuery().duedateHigherThenOrEquals(new Date(timerOneFireTime.getTime() + ONE_SECOND));
verifyQueryResults(query, 2);
query = managementService.createJobQuery().duedateHigherThenOrEquals(timerThreeFireTime);
verifyQueryResults(query, 1);
query = managementService.createJobQuery().duedateHigherThenOrEquals(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
verifyQueryResults(query, 0);
}
示例4: testCatchingTimerEvent
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(1, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the second timer should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertEquals(0, jobQuery.count());
assertProcessEnded(pi.getProcessInstanceId());
}
示例5: testCycleDateStartTimerEvent
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testCycleDateStartTimerEvent() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
moveByMinutes(5);
ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
assertEquals(1, piq.count());
assertEquals(1, jobQuery.count());
moveByMinutes(5);
assertEquals(2, piq.count());
assertEquals(1, jobQuery.count());
//have to manually delete pending timer
cleanDB();
}
示例6: testCycleWithLimitStartTimerEvent
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testCycleWithLimitStartTimerEvent() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
moveByMinutes(5);
ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExampleCycle");
assertEquals(1, piq.count());
assertEquals(1, jobQuery.count());
moveByMinutes(5);
assertEquals(2, piq.count());
assertEquals(0, jobQuery.count());
}
示例7: testVersionUpgradeShouldCancelJobs
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testVersionUpgradeShouldCancelJobs() throws Exception {
ClockUtil.setCurrentTime(new Date());
// 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 process = new String(IoUtil.readInputStream(getClass().getResourceAsStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml"), "")).replaceAll("beforeChange","changed");
String id = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml",
new ByteArrayInputStream(process.getBytes())).deploy().getId();
assertEquals(1, jobQuery.count());
moveByMinutes(5);
//we check that correct version was started
String pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").singleResult().getProcessInstanceId();
assertEquals("changed", runtimeService.getActiveActivityIds(pi).get(0));
assertEquals(1, jobQuery.count());
cleanDB();
repositoryService.deleteDeployment(id, true);
}
示例8: testMultipleTimersOnUserTask
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testMultipleTimersOnUserTask() {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be 3 timers created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("multipleTimersOnUserTask");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertEquals(3, jobs.size());
// After setting the clock to time '1 hour and 5 seconds', the second timer should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertEquals(0L, jobQuery.count());
// which means that the third task is reached
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Third Task", task.getName());
}
示例9: testExpressionOnTimer
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testExpressionOnTimer(){
// Set the clock fixed
Date startTime = new Date();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("duration", "PT1H");
// After process start, there should be a timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertEquals(1, jobs.size());
// After setting the clock to time '1 hour and 5 seconds', the second timer should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertEquals(0L, jobQuery.count());
// which means the process has ended
assertProcessEnded(pi.getId());
}
示例10: testCatchingTimerEvent
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be 3 timers created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(3, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the timers should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertEquals(0, jobQuery.count());
assertProcessEnded(pi.getProcessInstanceId());
}
示例11: testCatchingTimerEvent
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be 3 timers created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(3, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the timers should fire
ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 100L);
assertEquals(0, jobQuery.count());
assertProcessEnded(pi.getProcessInstanceId());
}
示例12: testTimerShouldNotBeRecreatedOnDeploymentCacheReboot
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Deployment
public void testTimerShouldNotBeRecreatedOnDeploymentCacheReboot() {
// Just to be sure, I added this test. Sounds like something that could easily happen
// when the order of deploy/parsing is altered.
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// Reset deployment cache
((ProcessEngineConfigurationImpl) processEngineConfiguration).getProcessDefinitionCache().clear();
// Start one instance of the process definition, this will trigger a cache reload
runtimeService.startProcessInstanceByKey("startTimer");
// No new jobs should have been created
assertEquals(1, jobQuery.count());
}
示例13: getJob
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
Job getJob(DelegateExecution context) {
JobQuery jobQuery = context.getEngineServices().getManagementService().createJobQuery();
if (jobQuery == null) {
return null;
}
return jobQuery.processInstanceId(context.getProcessInstanceId()).singleResult();
}
示例14: timers
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Override
public JobQuery timers() {
if (onlyMessages) {
throw new ActivitiIllegalArgumentException("Cannot combine onlyTimers() with onlyMessages() in the same query");
}
this.onlyTimers = true;
return this;
}
示例15: messages
import org.activiti.engine.runtime.JobQuery; //导入依赖的package包/类
@Override
public JobQuery messages() {
if (onlyTimers) {
throw new ActivitiIllegalArgumentException("Cannot combine onlyTimers() with onlyMessages() in the same query");
}
this.onlyMessages = true;
return this;
}