Here are the examples of the java api class org.camunda.bpm.engine.runtime.JobQuery taken from open source projects.
1. JobRestServiceInteractionTest#testJobGetIdDoesntExist()
Project: camunda-bpm-platform
File: JobRestServiceInteractionTest.java
File: JobRestServiceInteractionTest.java
@Test public void testJobGetIdDoesntExist() { JobQuery invalidQueryNonExistingJob; invalidQueryNonExistingJob = mock(JobQuery.class); when(mockManagementService.createJobQuery().jobId(MockProvider.NON_EXISTING_JOB_ID)).thenReturn(invalidQueryNonExistingJob); when(invalidQueryNonExistingJob.singleResult()).thenReturn(null); String jobId = MockProvider.NON_EXISTING_JOB_ID; given().pathParam("id", jobId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Job with id " + jobId + " does not exist")).when().get(SINGLE_JOB_RESOURCE_URL); }
2. JobRestServiceImpl#queryJobsCount()
Project: camunda-bpm-platform
File: JobRestServiceImpl.java
File: JobRestServiceImpl.java
@Override public CountResultDto queryJobsCount(JobQueryDto queryDto) { ProcessEngine engine = getProcessEngine(); queryDto.setObjectMapper(getObjectMapper()); JobQuery query = queryDto.toQuery(engine); long count = query.count(); CountResultDto result = new CountResultDto(); result.setCount(count); return result; }
3. JobRestServiceImpl#queryJobs()
Project: camunda-bpm-platform
File: JobRestServiceImpl.java
File: JobRestServiceImpl.java
@Override public List<JobDto> queryJobs(JobQueryDto queryDto, Integer firstResult, Integer maxResults) { ProcessEngine engine = getProcessEngine(); queryDto.setObjectMapper(getObjectMapper()); JobQuery query = queryDto.toQuery(engine); List<Job> matchingJobs; if (firstResult != null || maxResults != null) { matchingJobs = executePaginatedQuery(query, firstResult, maxResults); } else { matchingJobs = query.list(); } List<JobDto> jobResults = new ArrayList<JobDto>(); for (Job job : matchingJobs) { JobDto resultJob = JobDto.fromJob(job); jobResults.add(resultJob); } return jobResults; }
4. HistoricActivityInstanceTest#testUserTaskStillRunning()
Project: camunda-bpm-platform
File: HistoricActivityInstanceTest.java
File: HistoricActivityInstanceTest.java
@Deployment public void testUserTaskStillRunning() { runtimeService.startProcessInstanceByKey("nonInterruptingEvent"); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); managementService.executeJob(jobQuery.singleResult().getId()); HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("userTask"); assertEquals(1, historicActivityInstanceQuery.count()); assertNull(historicActivityInstanceQuery.singleResult().getEndTime()); historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end1"); assertEquals(0, historicActivityInstanceQuery.count()); historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("timer"); assertEquals(1, historicActivityInstanceQuery.count()); assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime()); historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end2"); assertEquals(1, historicActivityInstanceQuery.count()); assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime()); }
5. EventBasedGatewayTest#testTimeCycle()
Project: camunda-bpm-platform
File: EventBasedGatewayTest.java
File: EventBasedGatewayTest.java
@Deployment public void testTimeCycle() { String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); managementService.executeJob(jobId); assertEquals(0, jobQuery.count()); String taskId = taskService.createTaskQuery().singleResult().getId(); taskService.complete(taskId); assertProcessEnded(processInstanceId); }
6. ExclusiveTimerEventTest#testCatchingTimerEvent()
Project: camunda-bpm-platform
File: ExclusiveTimerEventTest.java
File: ExclusiveTimerEventTest.java
@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); assertEquals(0, jobQuery.count()); assertProcessEnded(pi.getProcessInstanceId()); }
7. StartTimerEventTest#testNonInterruptingTimeCycleInEventSubProcess()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testNonInterruptingTimeCycleInEventSubProcess() { // given runtimeService.startProcessInstanceByKey("process"); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); // when managementService.executeJob(jobId); // then assertEquals(1, jobQuery.count()); String anotherJobId = jobQuery.singleResult().getId(); assertFalse(jobId.equals(anotherJobId)); }
8. StartTimerEventTest#testTimeCycle()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testTimeCycle() { // given JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); // when managementService.executeJob(jobId); // then assertEquals(1, jobQuery.count()); String anotherJobId = jobQuery.singleResult().getId(); assertFalse(jobId.equals(anotherJobId)); }
9. StartTimerEventTest#testTimerShouldNotBeRecreatedOnDeploymentCacheReboot()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@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 processEngineConfiguration.getDeploymentCache().discardProcessDefinitionCache(); // 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()); }
10. StartTimerEventTest#testExpressionStartTimerEvent()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testExpressionStartTimerEvent() throws Exception { // ACT-1415: fixed start-date is an expression JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); ClockUtil.setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30")); executeAllJobs(); List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list(); assertEquals(1, pi.size()); assertEquals(0, jobQuery.count()); }
11. StartTimerEventTest#testFixedDateStartTimerEvent()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testFixedDateStartTimerEvent() throws Exception { // After process start, there should be timer created JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); ClockUtil.setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30")); executeAllJobs(); List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list(); assertEquals(1, pi.size()); assertEquals(0, jobQuery.count()); }
12. StartTimerEventTest#testDurationStartTimerEvent()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testDurationStartTimerEvent() throws Exception { // Set the clock fixed Date startTime = new Date(); // After process start, there should be timer created JobQuery jobQuery = managementService.createJobQuery(); 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))); executeAllJobs(); executeAllJobs(); List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list(); assertEquals(1, pi.size()); assertEquals(0, jobQuery.count()); }
13. IntermediateTimerEventTest#testTimeCycle()
Project: camunda-bpm-platform
File: IntermediateTimerEventTest.java
File: IntermediateTimerEventTest.java
@Deployment public void testTimeCycle() { String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId(); JobQuery query = managementService.createJobQuery(); assertEquals(1, query.count()); String jobId = query.singleResult().getId(); managementService.executeJob(jobId); assertEquals(0, query.count()); String taskId = taskService.createTaskQuery().singleResult().getId(); taskService.complete(taskId); assertProcessEnded(processInstanceId); }
14. IntermediateTimerEventTest#testCatchingTimerEvent()
Project: camunda-bpm-platform
File: IntermediateTimerEventTest.java
File: IntermediateTimerEventTest.java
@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); assertEquals(0, jobQuery.count()); assertProcessEnded(pi.getProcessInstanceId()); }
15. BoundaryTimerNonInterruptingEventTest#testTimeCycle()
Project: camunda-bpm-platform
File: BoundaryTimerNonInterruptingEventTest.java
File: BoundaryTimerNonInterruptingEventTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerNonInterruptingEventTest.testTimerWithCycle.bpmn20.xml" }) public void testTimeCycle() throws Exception { // given runtimeService.startProcessInstanceByKey("nonInterruptingCycle"); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); // when managementService.executeJob(jobId); // then assertEquals(1, jobQuery.count()); String anotherJobId = jobQuery.singleResult().getId(); assertFalse(jobId.equals(anotherJobId)); }
16. BoundaryTimerEventTest#testExpressionOnTimer()
Project: camunda-bpm-platform
File: BoundaryTimerEventTest.java
File: BoundaryTimerEventTest.java
@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); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
17. BoundaryTimerEventTest#testMultipleTimersOnUserTask()
Project: camunda-bpm-platform
File: BoundaryTimerEventTest.java
File: BoundaryTimerEventTest.java
/* * Test for when multiple boundary timer events are defined on the same user * task * * Configuration: - timer 1 -> 2 hours -> secondTask - timer 2 -> 1 hour -> * thirdTask - timer 3 -> 3 hours -> fourthTask * * See process image next to the process xml resource */ @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); assertEquals(0L, jobQuery.count()); // which means that the third task is reached Task task = taskService.createTaskQuery().singleResult(); assertEquals("Third Task", task.getName()); }
18. FoxJobRetryCmdTest#waitForExecutedJobWithRetriesLeft()
Project: camunda-bpm-platform
File: FoxJobRetryCmdTest.java
File: FoxJobRetryCmdTest.java
protected void waitForExecutedJobWithRetriesLeft(int retriesLeft, String jobId) { JobQuery jobQuery = managementService.createJobQuery(); if (jobId != null) { jobQuery.jobId(jobId); } Job job = jobQuery.singleResult(); try { managementService.executeJob(job.getId()); } catch (Exception e) { } // update job job = jobQuery.singleResult(); if (job.getRetries() != retriesLeft) { waitForExecutedJobWithRetriesLeft(retriesLeft, jobId); } }
19. MultiTenancyProcessInstanceSuspensionStateTest#activateProcessInstanceIncludingJobForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyProcessInstanceSuspensionStateTest.java
File: MultiTenancyProcessInstanceSuspensionStateTest.java
@Test public void activateProcessInstanceIncludingJobForNonTenant() { // given suspended jobs engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().singleResult().getTenantId(), is(nullValue())); }
20. MultiTenancyProcessInstanceSuspensionStateTest#activateProcessInstanceIncludingJobForTenant()
Project: camunda-bpm-platform
File: MultiTenancyProcessInstanceSuspensionStateTest.java
File: MultiTenancyProcessInstanceSuspensionStateTest.java
@Test public void activateProcessInstanceIncludingJobForTenant() { // given suspended job engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().tenantIdIn(TENANT_ONE).count(), is(1L)); }
21. MultiTenancyProcessInstanceSuspensionStateTest#suspendProcessInstanceIncludingJobForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyProcessInstanceSuspensionStateTest.java
File: MultiTenancyProcessInstanceSuspensionStateTest.java
@Test public void suspendProcessInstanceIncludingJobForNonTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().singleResult().getTenantId(), is(nullValue())); }
22. MultiTenancyProcessInstanceSuspensionStateTest#suspendProcessInstanceIncludingJobForTenant()
Project: camunda-bpm-platform
File: MultiTenancyProcessInstanceSuspensionStateTest.java
File: MultiTenancyProcessInstanceSuspensionStateTest.java
@Test public void suspendProcessInstanceIncludingJobForTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L)); }
23. MultiTenancyProcessInstanceSuspensionStateTest#suspendAndActivateProcessInstancesIncludingJobsForAllTenants()
Project: camunda-bpm-platform
File: MultiTenancyProcessInstanceSuspensionStateTest.java
File: MultiTenancyProcessInstanceSuspensionStateTest.java
@Test public void suspendAndActivateProcessInstancesIncludingJobsForAllTenants() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); // first suspend engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); // then activate engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).activate(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); }
24. MultiTenancyJobSuspensionStateTest#suspendJobDisabledTenantCheck()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendJobDisabledTenantCheck() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobsWithoutTenantId().count(), is(3L)); }
25. MultiTenancyJobSuspensionStateTest#suspendJobWithAuthenticatedTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendJobWithAuthenticatedTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getIdentityService().setAuthentication("user", null, Arrays.asList(TENANT_ONE)); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); engineRule.getIdentityService().clearAuthentication(); assertThat(query.active().count(), is(1L)); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().tenantIdIn(TENANT_TWO).count(), is(1L)); assertThat(query.suspended().withoutTenantId().count(), is(1L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L)); }
26. MultiTenancyJobSuspensionStateTest#suspendJobNoAuthenticatedTenants()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendJobNoAuthenticatedTenants() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); engineRule.getIdentityService().clearAuthentication(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().withoutTenantId().count(), is(1L)); }
27. MultiTenancyJobSuspensionStateTest#activateJobsForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void activateJobsForNonTenant() { // given suspend jobs engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.suspended().count(), is(3L)); assertThat(query.active().count(), is(0L)); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().withoutTenantId().count(), is(1L)); }
28. MultiTenancyJobSuspensionStateTest#activateJobsForTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void activateJobsForTenant() { // given suspend jobs engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.suspended().count(), is(3L)); assertThat(query.active().count(), is(0L)); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().tenantIdIn(TENANT_ONE).count(), is(1L)); }
29. MultiTenancyJobSuspensionStateTest#suspendJobsForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendJobsForNonTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().withoutTenantId().count(), is(1L)); }
30. MultiTenancyJobSuspensionStateTest#suspendJobForTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendJobForTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L)); }
31. MultiTenancyJobSuspensionStateTest#suspendAndActivateJobsForAllTenants()
Project: camunda-bpm-platform
File: MultiTenancyJobSuspensionStateTest.java
File: MultiTenancyJobSuspensionStateTest.java
@Test public void suspendAndActivateJobsForAllTenants() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); // first suspend engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); // then activate engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).activate(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); }
32. MultiTenancyJobDefinitionSuspensionStateTest#activateJobDefinitionIncludingJobsForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobDefinitionSuspensionStateTest.java
File: MultiTenancyJobDefinitionSuspensionStateTest.java
@Test public void activateJobDefinitionIncludingJobsForNonTenant() { // given suspend job definitions engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.suspended().count(), is(3L)); assertThat(query.active().count(), is(0L)); engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().includeJobs(true).activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().withoutTenantId().count(), is(1L)); }
33. MultiTenancyJobDefinitionSuspensionStateTest#activateJobDefinitionIncludingJobsForTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobDefinitionSuspensionStateTest.java
File: MultiTenancyJobDefinitionSuspensionStateTest.java
@Test public void activateJobDefinitionIncludingJobsForTenant() { // given suspend job definitions engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.suspended().count(), is(3L)); assertThat(query.active().count(), is(0L)); engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).includeJobs(true).activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().tenantIdIn(TENANT_ONE).count(), is(1L)); }
34. MultiTenancyJobDefinitionSuspensionStateTest#suspendJobDefinitionIncludingJobsForNonTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobDefinitionSuspensionStateTest.java
File: MultiTenancyJobDefinitionSuspensionStateTest.java
@Test public void suspendJobDefinitionIncludingJobsForNonTenant() { // given activated job definitions JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().includeJobs(true).suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().withoutTenantId().count(), is(1L)); }
35. MultiTenancyJobDefinitionSuspensionStateTest#suspendJobDefinitionIncludingJobsForTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobDefinitionSuspensionStateTest.java
File: MultiTenancyJobDefinitionSuspensionStateTest.java
@Test public void suspendJobDefinitionIncludingJobsForTenant() { // given activated job definitions JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).includeJobs(true).suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L)); }
36. MultiTenancyJobQueryTest#testQueryByTenantIdsIncludeJobsWithoutTenantId()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryByTenantIdsIncludeJobsWithoutTenantId() { JobQuery query = managementService.createJobQuery().tenantIdIn(TENANT_ONE).includeJobsWithoutTenantId(); assertThat(query.count(), is(2L)); query = managementService.createJobQuery().tenantIdIn(TENANT_TWO).includeJobsWithoutTenantId(); assertThat(query.count(), is(2L)); query = managementService.createJobQuery().tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobsWithoutTenantId(); assertThat(query.count(), is(3L)); }
37. MultiTenancyJobQueryTest#testQueryByTenantId()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryByTenantId() { JobQuery query = managementService.createJobQuery().tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); query = managementService.createJobQuery().tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); }
38. MultiTenancyTimerStartEventTest#deleteJobsWhileUndeployment()
Project: camunda-bpm-platform
File: MultiTenancyTimerStartEventTest.java
File: MultiTenancyTimerStartEventTest.java
@Test public void deleteJobsWhileUndeployment() { Deployment deploymentForTenantOne = testRule.deployForTenant(TENANT_ONE, PROCESS); Deployment deploymentForTenantTwo = testRule.deployForTenant(TENANT_TWO, PROCESS); JobQuery query = managementService.createJobQuery(); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantOne.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantTwo.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
39. SuspendJobTest#testSuspensionByProcessDefinitionKeyUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKeyUsingBuilder() { // given // a running process instance with a failed job runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // the failed job JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.active().count()); // when // the job will be suspended managementService.updateJobSuspensionState().byProcessDefinitionKey("suspensionProcess").suspend(); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); }
40. SuspendJobTest#testSuspensionByProcessInstanceIdUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessInstanceIdUsingBuilder() { // given // a running process instance with a failed job ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // the failed job JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.active().count()); // when // the job will be suspended managementService.updateJobSuspensionState().byProcessInstanceId(processInstance.getId()).suspend(); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); }
41. SuspendJobTest#testSuspensionByIdUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByIdUsingBuilder() { // given // a running process instance with a failed job runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.updateJobSuspensionState().byJobId(job.getId()).suspend(); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); }
42. ManagementServiceTest#testSetJobRetriesByJobDefinitionId()
Project: camunda-bpm-platform
File: ManagementServiceTest.java
File: ManagementServiceTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" }) public void testSetJobRetriesByJobDefinitionId() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution"); executeAvailableJobs(); JobQuery query = managementService.createJobQuery().processInstanceId(processInstance.getId()); JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); Job timerJob = query.singleResult(); assertNotNull("No job found for process instance", timerJob); assertEquals(0, timerJob.getRetries()); managementService.setJobRetriesByJobDefinitionId(jobDefinition.getId(), 5); timerJob = query.singleResult(); assertEquals(5, timerJob.getRetries()); }
43. JobQueryTest#testQueryByExceptionMessage()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" }) public void testQueryByExceptionMessage() { JobQuery query = managementService.createJobQuery().exceptionMessage(EXCEPTION_MESSAGE); verifyQueryResults(query, 0); ProcessInstance processInstance = startProcessInstanceWithFailingJob(); Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult(); query = managementService.createJobQuery().exceptionMessage(job.getExceptionMessage()); verifyFailedJob(query, processInstance); }
44. JobQueryTest#testQueryByDuedateHigherThenOrEqual()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
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); }
45. JobQueryTest#testQueryByDuedateHigherThen()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
public void testQueryByDuedateHigherThen() { JobQuery query = managementService.createJobQuery().duedateHigherThen(testStartTime); verifyQueryResults(query, 3); query = managementService.createJobQuery().duedateHigherThen(timerOneFireTime); verifyQueryResults(query, 2); query = managementService.createJobQuery().duedateHigherThen(timerTwoFireTime); verifyQueryResults(query, 1); query = managementService.createJobQuery().duedateHigherThen(timerThreeFireTime); verifyQueryResults(query, 0); }
46. JobQueryTest#testQueryByDuedateLowerThenOrEqual()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
public void testQueryByDuedateLowerThenOrEqual() { JobQuery query = managementService.createJobQuery().duedateLowerThenOrEquals(testStartTime); verifyQueryResults(query, 0); query = managementService.createJobQuery().duedateLowerThenOrEquals(timerOneFireTime); verifyQueryResults(query, 1); query = managementService.createJobQuery().duedateLowerThenOrEquals(timerTwoFireTime); verifyQueryResults(query, 2); query = managementService.createJobQuery().duedateLowerThenOrEquals(timerThreeFireTime); verifyQueryResults(query, 3); }
47. JobQueryTest#testQueryByDuedateLowerThen()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
public void testQueryByDuedateLowerThen() { JobQuery query = managementService.createJobQuery().duedateLowerThen(testStartTime); verifyQueryResults(query, 0); query = managementService.createJobQuery().duedateLowerThen(new Date(timerOneFireTime.getTime() + ONE_SECOND)); verifyQueryResults(query, 1); query = managementService.createJobQuery().duedateLowerThen(new Date(timerTwoFireTime.getTime() + ONE_SECOND)); verifyQueryResults(query, 2); query = managementService.createJobQuery().duedateLowerThen(new Date(timerThreeFireTime.getTime() + ONE_SECOND)); verifyQueryResults(query, 3); }
48. JobQueryTest#testQueryByExecutable()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
public void testQueryByExecutable() { // all jobs should be executable at t3 + 1hour.1second ClockUtil.setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND)); JobQuery query = managementService.createJobQuery().executable(); verifyQueryResults(query, 4); // Setting retries of one job to 0, makes it non-executable setRetries(processInstanceIdOne, 0); verifyQueryResults(query, 3); // Setting the clock before the start of the process instance, makes none of the jobs executable ClockUtil.setCurrentTime(testStartTime); // 1, since a message is always executable when retries > 0 verifyQueryResults(query, 1); }
49. JobQueryTest#testTimeCycleQueryByProcessDefinitionKey()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/JobQueryTest.testTimeCycleQueryByProcessDefinitionId.bpmn20.xml" }) public void testTimeCycleQueryByProcessDefinitionKey() { JobQuery query = managementService.createJobQuery().processDefinitionKey("process"); verifyQueryResults(query, 1); String jobId = query.singleResult().getId(); managementService.executeJob(jobId); verifyQueryResults(query, 1); String anotherJobId = query.singleResult().getId(); assertFalse(jobId.equals(anotherJobId)); }
50. JobQueryTest#testTimeCycleQueryByProcessDefinitionId()
Project: camunda-bpm-platform
File: JobQueryTest.java
File: JobQueryTest.java
@Deployment public void testTimeCycleQueryByProcessDefinitionId() { String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process").singleResult().getId(); JobQuery query = managementService.createJobQuery().processDefinitionId(processDefinitionId); verifyQueryResults(query, 1); String jobId = query.singleResult().getId(); managementService.executeJob(jobId); verifyQueryResults(query, 1); String anotherJobId = query.singleResult().getId(); assertFalse(jobId.equals(anotherJobId)); }
51. JobAuthorizationTest#testStandaloneJobQueryWithoutAuthorization()
Project: camunda-bpm-platform
File: JobAuthorizationTest.java
File: JobAuthorizationTest.java
// job query (standalone job) ///////////////////////////////// public void testStandaloneJobQueryWithoutAuthorization() { // given Date startTime = new Date(); ClockUtil.setCurrentTime(startTime); long oneWeekFromStartTime = startTime.getTime() + (7 * 24 * 60 * 60 * 1000); disableAuthorization(); // creates a new "standalone" job managementService.suspendJobDefinitionByProcessDefinitionKey(TIMER_START_PROCESS_KEY, true, new Date(oneWeekFromStartTime)); enableAuthorization(); // when JobQuery query = managementService.createJobQuery(); // then verifyQueryResults(query, 1); Job job = query.singleResult(); assertNotNull(job); assertNull(job.getProcessInstanceId()); assertNull(job.getProcessDefinitionKey()); deleteJob(job.getId()); }
52. JobAuthorizationTest#testQueryWithReadInstancePermissionOnAnyProcessDefinition()
Project: camunda-bpm-platform
File: JobAuthorizationTest.java
File: JobAuthorizationTest.java
public void testQueryWithReadInstancePermissionOnAnyProcessDefinition() { // given startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY); createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_INSTANCE); // when JobQuery query = managementService.createJobQuery(); // then verifyQueryResults(query, 2); }
53. JobAuthorizationTest#testQueryWithReadInstancePermissionOnTimerBoundaryProcessDefinition()
Project: camunda-bpm-platform
File: JobAuthorizationTest.java
File: JobAuthorizationTest.java
public void testQueryWithReadInstancePermissionOnTimerBoundaryProcessDefinition() { // given String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId(); createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, READ_INSTANCE); // when JobQuery query = managementService.createJobQuery(); // then verifyQueryResults(query, 1); Job job = query.singleResult(); assertEquals(processInstanceId, job.getProcessInstanceId()); assertEquals(TIMER_BOUNDARY_PROCESS_KEY, job.getProcessDefinitionKey()); }
54. JobAuthorizationTest#testQueryWithReadInstancePermissionOnTimerStartProcessDefinition()
Project: camunda-bpm-platform
File: JobAuthorizationTest.java
File: JobAuthorizationTest.java
public void testQueryWithReadInstancePermissionOnTimerStartProcessDefinition() { // given startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY); createGrantAuthorization(PROCESS_DEFINITION, TIMER_START_PROCESS_KEY, userId, READ_INSTANCE); // when JobQuery query = managementService.createJobQuery(); // then verifyQueryResults(query, 1); Job job = query.singleResult(); assertNull(job.getProcessInstanceId()); assertEquals(TIMER_START_PROCESS_KEY, job.getProcessDefinitionKey()); }
55. JobAuthorizationTest#testQueryWithMultiple()
Project: camunda-bpm-platform
File: JobAuthorizationTest.java
File: JobAuthorizationTest.java
public void testQueryWithMultiple() { // given String processInstanceId = startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY).getId(); createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when JobQuery query = managementService.createJobQuery(); // then verifyQueryResults(query, 2); }
56. StartTimerEventTest#testNonInterruptingFailingTimeCycleInEventSubProcess()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testNonInterruptingFailingTimeCycleInEventSubProcess() { // given runtimeService.startProcessInstanceByKey("process"); JobQuery failedJobQuery = managementService.createJobQuery(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); failedJobQuery.jobId(jobId); // when (1) try { managementService.executeJob(jobId); fail(); } catch (Exception e) { } // then (1) Job failedJob = failedJobQuery.singleResult(); assertEquals(2, failedJob.getRetries()); // a new timer job has been created assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); // when (2) try { managementService.executeJob(jobId); } catch (Exception e) { } // then (2) failedJob = failedJobQuery.singleResult(); assertEquals(1, failedJob.getRetries()); // there are still two jobs assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); }
57. StartTimerEventTest#testFailingTimeCycle()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testFailingTimeCycle() throws Exception { // given JobQuery query = managementService.createJobQuery(); JobQuery failedJobQuery = managementService.createJobQuery(); // a job to start a process instance assertEquals(1, query.count()); String jobId = query.singleResult().getId(); failedJobQuery.jobId(jobId); moveByMinutes(5); // when (1) try { managementService.executeJob(jobId); } catch (Exception e) { } // then (1) Job failedJob = failedJobQuery.singleResult(); assertEquals(2, failedJob.getRetries()); // a new timer job has been created assertEquals(2, query.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); // when (2) try { managementService.executeJob(jobId); } catch (Exception e) { } // then (2) failedJob = failedJobQuery.singleResult(); assertEquals(1, failedJob.getRetries()); // there are still two jobs assertEquals(2, query.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); }
58. BoundaryTimerNonInterruptingEventTest#testFailingTimeCycle()
Project: camunda-bpm-platform
File: BoundaryTimerNonInterruptingEventTest.java
File: BoundaryTimerNonInterruptingEventTest.java
@Deployment public void testFailingTimeCycle() { // given runtimeService.startProcessInstanceByKey("process"); JobQuery failedJobQuery = managementService.createJobQuery(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); String jobId = jobQuery.singleResult().getId(); failedJobQuery.jobId(jobId); // when (1) try { managementService.executeJob(jobId); fail(); } catch (Exception e) { } // then (1) Job failedJob = failedJobQuery.singleResult(); assertEquals(2, failedJob.getRetries()); // a new timer job has been created assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); // when (2) try { managementService.executeJob(jobId); } catch (Exception e) { } // then (2) failedJob = failedJobQuery.singleResult(); assertEquals(1, failedJob.getRetries()); // there are still two jobs assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); }
59. StartTimerEventTest#testNonInterruptingStartTimerEventSubProcessWithParallelMultiInstance()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testNonInterruptingStartTimerEventSubProcessWithParallelMultiInstance() { DummyServiceTask.wasExecuted = false; // start process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingParallelMultiInstance"); // check if execution exists ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()); assertEquals(6, executionQuery.count()); // check if user task exists TaskQuery taskQuery = taskService.createTaskQuery(); assertEquals(2, taskQuery.count()); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(2, jobQuery.count()); // execute all timer jobs for (Job job : jobQuery.list()) { managementService.executeJob(job.getId()); assertEquals(true, DummyServiceTask.wasExecuted); DummyServiceTask.wasExecuted = false; } assertEquals(0, jobQuery.count()); // check if user task doesn't exist because timer start event is // interrupting assertEquals(2, taskQuery.count()); // check if execution doesn't exist because timer start event is // interrupting assertEquals(6, executionQuery.count()); // check if process instance doesn't exist because timer start event is // interrupting ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()); assertEquals(1, processInstanceQuery.count()); }
60. StartTimerEventTest#testStartTimerEventSubProcessInParallelMultiInstanceSubProcess()
Project: camunda-bpm-platform
File: StartTimerEventTest.java
File: StartTimerEventTest.java
@Deployment public void testStartTimerEventSubProcessInParallelMultiInstanceSubProcess() { DummyServiceTask.wasExecuted = false; // start process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventSubProcessInParallelMultiInstanceSubProcess"); // check if execution exists ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()); assertEquals(6, executionQuery.count()); // check if user task exists TaskQuery taskQuery = taskService.createTaskQuery(); assertEquals(2, taskQuery.count()); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(2, jobQuery.count()); // execute timer job for (Job job : jobQuery.list()) { managementService.executeJob(job.getId()); assertEquals(true, DummyServiceTask.wasExecuted); DummyServiceTask.wasExecuted = false; } // check if user task doesn't exist because timer start event is // interrupting assertEquals(0, taskQuery.count()); // check if execution doesn't exist because timer start event is // interrupting assertEquals(0, executionQuery.count()); // check if process instance doesn't exist because timer start event is // interrupting ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()); assertEquals(0, processInstanceQuery.count()); }
61. ProcessDefinitionSuspensionTest#testSuspendByIdAndIncludeInstancesFlag_shouldSuspendAlsoJobDefinitionAndRetainJob()
Project: camunda-bpm-platform
File: ProcessDefinitionSuspensionTest.java
File: ProcessDefinitionSuspensionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/repository/ProcessDefinitionSuspensionTest.testWithOneAsyncServiceTask.bpmn" }) public void testSuspendByIdAndIncludeInstancesFlag_shouldSuspendAlsoJobDefinitionAndRetainJob() { // a process definition with a asynchronous continuation, so that there // exists a job definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // a running process instance with a failed service task Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceById(processDefinition.getId(), params); // when // the process definition will be suspended repositoryService.suspendProcessDefinitionById(processDefinition.getId(), false, null); // then // the job definition should be suspended... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and the corresponding job should be still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job job = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), job.getJobDefinitionId()); assertFalse(job.isSuspended()); }
62. ProcessDefinitionSuspensionTest#testSuspendByKey_shouldSuspendJobDefinitionAndRetainJob()
Project: camunda-bpm-platform
File: ProcessDefinitionSuspensionTest.java
File: ProcessDefinitionSuspensionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/repository/ProcessDefinitionSuspensionTest.testWithOneAsyncServiceTask.bpmn" }) public void testSuspendByKey_shouldSuspendJobDefinitionAndRetainJob() { // given // a process definition with a asynchronous continuation, so that there // exists a job definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // a running process instance with a failed service task Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceById(processDefinition.getId(), params); // when // the process definition will be suspended repositoryService.suspendProcessDefinitionByKey(processDefinition.getKey()); // then // the job definition should be suspended... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and the corresponding job should be still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job job = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), job.getJobDefinitionId()); assertFalse(job.isSuspended()); }
63. ProcessDefinitionSuspensionTest#testSuspendById_shouldSuspendJobDefinitionAndRetainJob()
Project: camunda-bpm-platform
File: ProcessDefinitionSuspensionTest.java
File: ProcessDefinitionSuspensionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/repository/ProcessDefinitionSuspensionTest.testWithOneAsyncServiceTask.bpmn" }) public void testSuspendById_shouldSuspendJobDefinitionAndRetainJob() { // given // a process definition with a asynchronous continuation, so that there // exists a job definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // a running process instance with a failed service task Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceById(processDefinition.getId(), params); // when // the process definition will be suspended repositoryService.suspendProcessDefinitionById(processDefinition.getId()); // then // the job definition should be suspended... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and the corresponding job should be still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job job = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), job.getJobDefinitionId()); assertFalse(job.isSuspended()); }
64. MultiTenancyJobDefinitionSuspensionStateTest#suspendAndActivateJobDefinitionsIncludingJobsForAllTenants()
Project: camunda-bpm-platform
File: MultiTenancyJobDefinitionSuspensionStateTest.java
File: MultiTenancyJobDefinitionSuspensionStateTest.java
@Test public void suspendAndActivateJobDefinitionsIncludingJobsForAllTenants() { // given activated job definitions JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); // first suspend engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).suspend(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); // then activate engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).includeJobs(true).activate(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); }
65. MultiTenancyJobQueryTest#testQueryDisabledTenantCheck()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); JobQuery query = managementService.createJobQuery(); assertThat(query.count(), is(3L)); }
66. MultiTenancyJobQueryTest#testQueryAuthenticatedTenants()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); JobQuery query = managementService.createJobQuery(); assertThat(query.count(), is(3L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); assertThat(query.withoutTenantId().count(), is(1L)); }
67. MultiTenancyJobQueryTest#testQueryAuthenticatedTenant()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); JobQuery query = managementService.createJobQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobsWithoutTenantId().count(), is(2L)); }
68. MultiTenancyJobQueryTest#testQueryNoAuthenticatedTenants()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryNoAuthenticatedTenants() { identityService.setAuthentication("user", null, null); JobQuery query = managementService.createJobQuery(); assertThat(query.count(), is(1L)); }
69. MultiTenancyJobQueryTest#testQueryByNonExistingTenantId()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryByNonExistingTenantId() { JobQuery query = managementService.createJobQuery().tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
70. MultiTenancyJobQueryTest#testQueryByJobsWithoutTenantId()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryByJobsWithoutTenantId() { JobQuery query = managementService.createJobQuery().withoutTenantId(); assertThat(query.count(), is(1L)); }
71. MultiTenancyJobQueryTest#testQueryByTenantIds()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryByTenantIds() { JobQuery query = managementService.createJobQuery().tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
72. MultiTenancyJobQueryTest#testQueryNoTenantIdSet()
Project: camunda-bpm-platform
File: MultiTenancyJobQueryTest.java
File: MultiTenancyJobQueryTest.java
public void testQueryNoTenantIdSet() { JobQuery query = managementService.createJobQuery(); assertThat(query.count(), is(3L)); }
73. MultiTenancyTimerStartEventTest#dontCreateNewJobsWhileReDeployment()
Project: camunda-bpm-platform
File: MultiTenancyTimerStartEventTest.java
File: MultiTenancyTimerStartEventTest.java
@Test public void dontCreateNewJobsWhileReDeployment() { testRule.deployForTenant(TENANT_ONE, PROCESS); testRule.deployForTenant(TENANT_TWO, PROCESS); testRule.deployForTenant(TENANT_ONE, PROCESS); JobQuery query = managementService.createJobQuery(); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
74. SuspendJobTest#testSuspensionByProcessDefinitionIdUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionIdUsingBuilder() { // given // a running process instance with a failed job runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // the failed job JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.active().count()); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // when // the job will be suspended managementService.updateJobSuspensionState().byProcessDefinitionId(processDefinition.getId()).suspend(); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); }
75. SuspendJobTest#testSuspensionByJobDefinitionIdUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByJobDefinitionIdUsingBuilder() { // given // a running process instance with a failed job runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // the failed job JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.active().count()); JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // the job will be suspended managementService.updateJobSuspensionState().byJobDefinitionId(jobDefinition.getId()).suspend(); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); }
76. SuspendJobTest#testMultipleSuspensionByProcessDefinitionKey_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
public void testMultipleSuspensionByProcessDefinitionKey_shouldSuspendJob() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // when // the job will be suspended managementService.suspendJobByProcessDefinitionKey(key); // then // the job should be suspended JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.active().count()); assertEquals(3, jobQuery.suspended().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
77. SuspendJobTest#testSuspensionByProcessDefinitionKey_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldSuspendJob() { // given // a deployed process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.suspendJobByProcessDefinitionKey(processDefinition.getKey()); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(job.getId(), suspendedJob.getId()); assertTrue(suspendedJob.isSuspended()); }
78. SuspendJobTest#testSuspensionByProcessDefinitionId_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionId_shouldSuspendJob() { // given // a deployed process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.suspendJobByProcessDefinitionId(processDefinition.getId()); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(job.getId(), suspendedJob.getId()); assertTrue(suspendedJob.isSuspended()); }
79. SuspendJobTest#testSuspensionByProcessInstanceId_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessInstanceId_shouldSuspendJob() { // given // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("suspensionProcess", params); // the job definition JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.suspendJobByProcessInstanceId(processInstance.getId()); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(job.getId(), suspendedJob.getId()); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
80. SuspendJobTest#testSuspensionByJobDefinitionId_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByJobDefinitionId_shouldSuspendJob() { // given // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // the job definition JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.suspendJobByJobDefinitionId(jobDefinition.getId()); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(job.getId(), suspendedJob.getId()); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
81. SuspendJobTest#testSuspensionById_shouldSuspendJob()
Project: camunda-bpm-platform
File: SuspendJobTest.java
File: SuspendJobTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionById_shouldSuspendJob() { // given // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // the failed job JobQuery jobQuery = managementService.createJobQuery(); Job job = jobQuery.singleResult(); assertFalse(job.isSuspended()); // when // the job will be suspended managementService.suspendJobById(job.getId()); // then // the job should be suspended assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(job.getId(), suspendedJob.getId()); assertTrue(suspendedJob.isSuspended()); }
82. SuspendJobDefinitionTest#testSuspensionJobDefinitionIncludeJobsdUsingBuilder()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionJobDefinitionIncludeJobsdUsingBuilder() { // given // a deployed process definition with asynchronous continuation // a running process instance with a failed job runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true)); // a job definition (which was created for the asynchronous continuation) JobDefinitionQuery query = managementService.createJobDefinitionQuery(); JobDefinition jobDefinition = query.singleResult(); assertFalse(jobDefinition.isSuspended()); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); // when // suspend the job definition and the job managementService.updateJobDefinitionSuspensionState().byJobDefinitionId(jobDefinition.getId()).includeJobs(true).suspend(); // then // there exists a suspended job definition and job assertEquals(1, query.suspended().count()); assertEquals(1, jobQuery.suspended().count()); assertEquals(0, jobQuery.active().count()); }
83. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndSuspendJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, true, oneWeekLater()); // then // the job definitions are still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); // the job definition should be suspended assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(3, jobDefinitionQuery.suspended().count()); // the corresponding jobs are suspended jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.active().count()); assertEquals(3, jobQuery.suspended().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
84. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndRetainJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, false, oneWeekLater()); // then // the job definition is still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(3, jobDefinitionQuery.suspended().count()); // but the jobs are still active jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(3, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
85. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndSuspendJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, true, null); // then // all job definitions are suspended JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.suspended().count()); assertEquals(0, jobDefinitionQuery.active().count()); // and the jobs too JobQuery jobQuery = managementService.createJobQuery(); assertEquals(3, jobQuery.suspended().count()); assertEquals(0, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
86. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndRetainJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, false, null); // then // all job definitions are suspended JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.suspended().count()); assertEquals(0, jobDefinitionQuery.active().count()); // but the jobs are still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(3, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
87. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldSuspendJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, true); // then // all job definitions are suspended JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.suspended().count()); assertEquals(0, jobDefinitionQuery.active().count()); // and the jobs too JobQuery jobQuery = managementService.createJobQuery(); assertEquals(3, jobQuery.suspended().count()); assertEquals(0, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
88. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
public void testMultipleSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldRetainJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key, false); // then // all job definitions are suspended JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.suspended().count()); assertEquals(0, jobDefinitionQuery.active().count()); // but the jobs are still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(3, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
89. SuspendJobDefinitionTest#testMultipleSuspensionByProcessDefinitionKey_shouldRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
// Test ManagementService#suspendJobDefinitionByProcessDefinitionKey() with multiple process definition // with same process definition key public void testMultipleSuspensionByProcessDefinitionKey_shouldRetainJobs() { // given String key = "suspensionProcess"; // Deploy three processes and start for each deployment a process instance // with a failed job int nrOfProcessDefinitions = 3; for (int i = 0; i < nrOfProcessDefinitions; i++) { repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy(); Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey(key, params); } // a job definition (which was created for the asynchronous continuation) // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(key); // then // all job definitions are suspended JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(3, jobDefinitionQuery.suspended().count()); assertEquals(0, jobDefinitionQuery.active().count()); // but the jobs are still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(3, jobQuery.active().count()); // Clean DB for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) { repositoryService.deleteDeployment(deployment.getId(), true); } }
90. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndSuspendJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), true, oneWeekLater()); // then // the job definition is still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(1, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); // the job definition should be suspended assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is suspended jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
91. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldExecuteDelayedAndRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), false, oneWeekLater()); // then // the job definition is still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(1, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); // the job definition should be suspended assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is still active jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job activeJob = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); }
92. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndSuspendJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), true, null); // then // there exists a suspended job definition... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and a suspended job of the provided job definition JobQuery jobQuery = managementService.createJobQuery().suspended(); assertEquals(1, jobQuery.count()); Job suspendedJob = jobQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
93. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldExecuteImmediatelyAndRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), false, null); // then // there exists a suspended job definition JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job activeJob = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); }
94. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldSuspendJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), true); // then // there exists a suspended job definition... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and a suspended job of the provided job definition JobQuery jobQuery = managementService.createJobQuery().suspended(); assertEquals(1, jobQuery.count()); Job suspendedJob = jobQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
95. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKeyAndSuspendJobsFlag_shouldRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey(), false); // then // there exists a suspended job definition JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job activeJob = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); }
96. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionKey_shouldRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionKey_shouldRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinition.getKey()); // then // there exists a suspended job definition JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); // there does not exist any active job definition jobDefinitionQuery = managementService.createJobDefinitionQuery().active(); assertTrue(jobDefinitionQuery.list().isEmpty()); // the corresponding job is still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job activeJob = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); }
97. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionId_shouldExecuteDelayedAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionId_shouldExecuteDelayedAndSuspendJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId(), true, oneWeekLater()); // then // the job definition is still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(1, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); // the job definition should be suspended assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is suspended jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.active().count()); assertEquals(1, jobQuery.suspended().count()); Job suspendedJob = jobQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
98. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionId_shouldExecuteDelayedAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionId_shouldExecuteDelayedAndRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId(), false, oneWeekLater()); // then // the job definition is still active JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery(); assertEquals(1, jobDefinitionQuery.active().count()); assertEquals(0, jobDefinitionQuery.suspended().count()); // there exists a job for the delayed suspension execution JobQuery jobQuery = managementService.createJobQuery(); Job delayedSuspensionJob = jobQuery.timers().active().singleResult(); assertNotNull(delayedSuspensionJob); // execute job managementService.executeJob(delayedSuspensionJob.getId()); // the job definition should be suspended assertEquals(0, jobDefinitionQuery.active().count()); assertEquals(1, jobDefinitionQuery.suspended().count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.suspended().singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is still active jobQuery = managementService.createJobQuery().active(); assertEquals(1, jobQuery.count()); Job activeJob = jobQuery.singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); jobQuery = managementService.createJobQuery().suspended(); assertEquals(0, jobQuery.count()); }
99. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionId_shouldExecuteImmediatelyAndSuspendJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionId_shouldExecuteImmediatelyAndSuspendJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId(), true, null); // then // there exists a suspended job definition... JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // ...and a suspended job of the provided job definition JobQuery jobQuery = managementService.createJobQuery().suspended(); assertEquals(1, jobQuery.count()); Job suspendedJob = jobQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId()); assertTrue(suspendedJob.isSuspended()); }
100. SuspendJobDefinitionTest#testSuspensionByProcessDefinitionId_shouldExecuteImmediatelyAndRetainJobs()
Project: camunda-bpm-platform
File: SuspendJobDefinitionTest.java
File: SuspendJobDefinitionTest.java
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" }) public void testSuspensionByProcessDefinitionId_shouldExecuteImmediatelyAndRetainJobs() { // given // a deployed process definition with asynchronous continuation ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // a running process instance with a failed job Map<String, Object> params = new HashMap<String, Object>(); params.put("fail", Boolean.TRUE); runtimeService.startProcessInstanceByKey("suspensionProcess", params); // a job definition (which was created for the asynchronous continuation) JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult(); // when // suspend the job definition managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId(), false, null); // then // there exists a suspended job definition JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended(); assertEquals(1, jobDefinitionQuery.count()); JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult(); assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId()); assertTrue(suspendedJobDefinition.isSuspended()); // the corresponding job is still active JobQuery jobQuery = managementService.createJobQuery(); assertEquals(0, jobQuery.suspended().count()); assertEquals(1, jobQuery.active().count()); Job activeJob = jobQuery.active().singleResult(); assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId()); assertFalse(activeJob.isSuspended()); }