use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class RuntimeServiceAsyncOperationsTest method testDeleteProcessInstancesAsyncWithListInDifferentDeployments.
@Test
public void testDeleteProcessInstancesAsyncWithListInDifferentDeployments() {
// given
ProcessDefinition sourceDefinition1 = testRule.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "ONE_TASK_PROCESS"));
ProcessDefinition sourceDefinition2 = testRule.deployAndGetDefinition(modify(ProcessModels.TWO_TASKS_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "TWO_TASKS_PROCESS"));
List<String> processInstanceIds = createProcessInstances(sourceDefinition1, sourceDefinition2, 15, 10);
final String firstDeploymentId = sourceDefinition1.getDeploymentId();
final String secondDeploymentId = sourceDefinition2.getDeploymentId();
List<String> processInstanceIdsFromFirstDeployment = getProcessInstanceIdsByDeploymentId(firstDeploymentId);
List<String> processInstanceIdsFromSecondDeployment = getProcessInstanceIdsByDeploymentId(secondDeploymentId);
engineRule.getProcessEngineConfiguration().setInvocationsPerBatchJob(2);
engineRule.getProcessEngineConfiguration().setBatchJobsPerSeed(3);
// when
Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceIds, null, "test_reason");
String seedJobDefinitionId = batch.getSeedJobDefinitionId();
// seed jobs
int expectedSeedJobsCount = 5;
createAndExecuteSeedJobs(seedJobDefinitionId, expectedSeedJobsCount);
// then
List<Job> jobs = managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()).list();
// execute jobs related to the first deployment
List<String> jobIdsForFirstDeployment = getJobIdsByDeployment(jobs, firstDeploymentId);
assertNotNull(jobIdsForFirstDeployment);
for (String jobId : jobIdsForFirstDeployment) {
managementService.executeJob(jobId);
}
// the process instances related to the first deployment should be deleted
assertEquals(0, runtimeService.createProcessInstanceQuery().deploymentId(firstDeploymentId).count());
assertHistoricTaskDeletionPresent(processInstanceIdsFromFirstDeployment, "test_reason", testRule);
// and process instances related to the second deployment should not be deleted
assertEquals(processInstanceIdsFromSecondDeployment.size(), runtimeService.createProcessInstanceQuery().deploymentId(secondDeploymentId).count());
assertHistoricTaskDeletionPresent(processInstanceIdsFromSecondDeployment, null, testRule);
// execute jobs related to the second deployment
List<String> jobIdsForSecondDeployment = getJobIdsByDeployment(jobs, secondDeploymentId);
assertNotNull(jobIdsForSecondDeployment);
for (String jobId : jobIdsForSecondDeployment) {
managementService.executeJob(jobId);
}
// all of the process instances should be deleted
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationEventBasedGatewayTest method testMigrateGatewayWithTimerEventChangeId.
@Test
public void testMigrateGatewayWithTimerEventChangeId() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.TIMER_EVENT_BASED_GW_PROCESS).changeElementId("timerCatch", "newTimerCatch"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("timerCatch", "newTimerCatch").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertIntermediateTimerJobMigrated("timerCatch", "newTimerCatch");
Job timerJob = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(timerJob.getId());
testHelper.completeTask("afterTimerCatch");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTestRule method assertJobRemoved.
public void assertJobRemoved(String activityId, String handlerType) {
JobDefinition jobDefinitionBefore = snapshotBeforeMigration.getJobDefinitionForActivityIdAndType(activityId, handlerType);
assertNotNull("Expected that a job definition for activity '" + activityId + "' exists before migration", jobDefinitionBefore);
Job jobBefore = snapshotBeforeMigration.getJobForDefinitionId(jobDefinitionBefore.getId());
assertNotNull("Expected that a job for activity '" + activityId + "' exists before migration", jobBefore);
assertTimerJob(jobBefore);
for (Job job : snapshotAfterMigration.getJobs()) {
if (jobBefore.getId().equals(job.getId())) {
fail("Expected job '" + jobBefore.getId() + "' to be removed after migration");
}
}
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTestRule method triggerTimer.
public void triggerTimer() {
Job job = assertTimerJobExists(snapshotAfterMigration);
processEngine.getManagementService().executeJob(job.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTestRule method assertTimerJobExists.
public Job assertTimerJobExists(ProcessInstanceSnapshot snapshot) {
List<Job> jobs = snapshot.getJobs();
assertEquals(1, jobs.size());
Job job = jobs.get(0);
assertTimerJob(job);
return job;
}
Aggregations