use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessDefinitionSuspensionStateTest method delayedSuspendProcessDefinitionsForTenant.
@Test
public void delayedSuspendProcessDefinitionsForTenant() {
// given activated process definitions
engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).executionDate(tomorrow()).suspend();
ProcessDefinitionQuery query = engineRule.getRepositoryService().createProcessDefinitionQuery();
assertThat(query.active().count(), is(3L));
assertThat(query.suspended().count(), is(0L));
// when execute the job to suspend the process definition
Job job = engineRule.getManagementService().createJobQuery().timers().singleResult();
assertThat(job, is(notNullValue()));
engineRule.getManagementService().executeJob(job.getId());
assertThat(query.active().count(), is(2L));
assertThat(query.suspended().count(), is(1L));
assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L));
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartBeforeEventSubscription.
@Deployment(resources = SUBPROCESS_BOUNDARY_EVENTS_PROCESS)
public void testStartBeforeEventSubscription() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess");
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").execute();
// then two timer jobs should have been created
assertEquals(2, managementService.createJobQuery().count());
Job innerJob = managementService.createJobQuery().activityId("innerTimer").singleResult();
assertNotNull(innerJob);
assertEquals(runtimeService.createExecutionQuery().activityId("innerTask").singleResult().getId(), innerJob.getExecutionId());
Job outerJob = managementService.createJobQuery().activityId("outerTimer").singleResult();
assertNotNull(outerJob);
// when executing the jobs
managementService.executeJob(innerJob.getId());
Task innerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("innerAfterBoundaryTask").singleResult();
assertNotNull(innerBoundaryTask);
managementService.executeJob(outerJob.getId());
Task outerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("outerAfterBoundaryTask").singleResult();
assertNotNull(outerBoundaryTask);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchWithFailedExecutionJobDeletionWithCascade.
@Test
public void testBatchWithFailedExecutionJobDeletionWithCascade() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
helper.executeSeedJob(batch);
// create incidents
List<Job> executionJobs = helper.getExecutionJobs(batch);
for (Job executionJob : executionJobs) {
engineRule.getManagementService().setJobRetries(executionJob.getId(), 0);
}
engineRule.getManagementService().deleteBatch(batch.getId(), true);
// then the no historic incidents exists
long historicIncidents = engineRule.getHistoryService().createHistoricIncidentQuery().count();
assertEquals(0, historicIncidents);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method testBatchWithFailedSeedJobDeletionWithCascade.
@Test
public void testBatchWithFailedSeedJobDeletionWithCascade() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
// create incident
Job seedJob = helper.getSeedJob(batch);
engineRule.getManagementService().setJobRetries(seedJob.getId(), 0);
engineRule.getManagementService().deleteBatch(batch.getId(), true);
// then the no historic incidents exists
long historicIncidents = engineRule.getHistoryService().createHistoricIncidentQuery().count();
assertEquals(0, historicIncidents);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class RuntimeServiceAsyncOperationsTest method createAndExecuteSeedJobs.
private void createAndExecuteSeedJobs(String seedJobDefinitionId, int expectedSeedJobsCount) {
for (int i = 0; i <= expectedSeedJobsCount; i++) {
Job seedJob = managementService.createJobQuery().jobDefinitionId(seedJobDefinitionId).singleResult();
if (i != expectedSeedJobsCount) {
assertNotNull(seedJob);
managementService.executeJob(seedJob.getId());
} else {
// the last seed job should not trigger another seed job
assertNull(seedJob);
}
}
}
Aggregations