use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchMigrationTest method testMonitorJobCreation.
@Test
public void testMonitorJobCreation() {
Batch batch = helper.migrateProcessInstancesAsync(10);
// when
helper.executeSeedJob(batch);
// then the seed job definition still exists but the seed job is removed
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
assertNotNull(seedJobDefinition);
Job seedJob = helper.getSeedJob(batch);
assertNull(seedJob);
// and a monitor job definition and job exists
JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);
assertNotNull(monitorJobDefinition);
Job monitorJob = helper.getMonitorJob(batch);
assertNotNull(monitorJob);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchMigrationTest method testMigrationJobsCreation.
@Test
public void testMigrationJobsCreation() {
// reduce number of batch jobs per seed to not have to create a lot of instances
engineRule.getProcessEngineConfiguration().setBatchJobsPerSeed(10);
Batch batch = helper.migrateProcessInstancesAsync(20);
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
JobDefinition migrationJobDefinition = helper.getExecutionJobDefinition(batch);
String sourceDeploymentId = helper.getSourceProcessDefinition().getDeploymentId();
// when
helper.executeSeedJob(batch);
// then there exist migration jobs
List<Job> migrationJobs = helper.getJobsForDefinition(migrationJobDefinition);
assertEquals(10, migrationJobs.size());
for (Job migrationJob : migrationJobs) {
assertEquals(migrationJobDefinition.getId(), migrationJob.getJobDefinitionId());
assertNull(migrationJob.getDuedate());
assertEquals(sourceDeploymentId, migrationJob.getDeploymentId());
assertNull(migrationJob.getProcessDefinitionId());
assertNull(migrationJob.getProcessDefinitionKey());
assertNull(migrationJob.getProcessInstanceId());
assertNull(migrationJob.getExecutionId());
}
// and the seed job still exists
Job seedJob = helper.getJobForDefinition(seedJobDefinition);
assertNotNull(seedJob);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class MigrationHistoricIncidentTest method testMigrateHistoricIncident.
@Test
public void testMigrateHistoricIncident() {
// given
ProcessDefinition sourceProcess = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS);
ProcessDefinition targetProcess = testHelper.deployAndGetDefinition(modify(AsyncProcessModels.ASYNC_BEFORE_USER_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY).changeElementId("userTask", "newUserTask"));
JobDefinition targetJobDefinition = managementService.createJobDefinitionQuery().processDefinitionId(targetProcess.getId()).singleResult();
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcess.getId(), targetProcess.getId()).mapActivities("userTask", "newUserTask").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcess.getId());
Job job = managementService.createJobQuery().singleResult();
managementService.setJobRetries(job.getId(), 0);
HistoricIncident incidentBeforeMigration = historyService.createHistoricIncidentQuery().singleResult();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
Assert.assertNotNull(historicIncident);
Assert.assertEquals("newUserTask", historicIncident.getActivityId());
Assert.assertEquals(targetJobDefinition.getId(), historicIncident.getJobDefinitionId());
Assert.assertEquals(targetProcess.getId(), historicIncident.getProcessDefinitionId());
Assert.assertEquals(targetProcess.getKey(), historicIncident.getProcessDefinitionKey());
Assert.assertEquals(processInstance.getId(), historicIncident.getExecutionId());
// and other properties have not changed
Assert.assertEquals(incidentBeforeMigration.getCreateTime(), historicIncident.getCreateTime());
Assert.assertEquals(incidentBeforeMigration.getProcessInstanceId(), historicIncident.getProcessInstanceId());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class AsyncParallelMultiInstanceScenarioTest method testInitAsyncBeforeSubprocessJobDefinition.
/**
* Note: this test is not really isolated since the job
* definition is migrated when the process definition is accessed the first time.
* This might happen already before this test case is executed.
*/
@Test
@ScenarioUnderTest("initAsyncBeforeSubprocess.4")
public void testInitAsyncBeforeSubprocessJobDefinition() {
// when the process is redeployed into the cache (instantiation should trigger that)
rule.getRuntimeService().startProcessInstanceByKey("AsyncBeforeParallelMultiInstanceSubprocess");
// then the old job definition referencing "miSubProcess" has been migrated
JobDefinition asyncJobDefinition = rule.jobDefinitionQuery().singleResult();
Assert.assertEquals("miSubProcess#multiInstanceBody", asyncJobDefinition.getActivityId());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class AsyncParallelMultiInstanceScenarioTest method testInitAsyncBeforeTaskJobDefinition.
/**
* Note: this test is not really isolated since the job
* definition is migrated when the process definition is accessed the first time.
* This might happen already before this test case is executed.
*/
@Test
@ScenarioUnderTest("initAsyncBeforeTask.4")
public void testInitAsyncBeforeTaskJobDefinition() {
// when the process is redeployed into the cache (instantiation should trigger that)
rule.getRuntimeService().startProcessInstanceByKey("AsyncBeforeParallelMultiInstanceTask");
// then the old job definition referencing "miSubProcess" has been migrated
JobDefinition asyncJobDefinition = rule.jobDefinitionQuery().singleResult();
Assert.assertEquals("miTask#multiInstanceBody", asyncJobDefinition.getActivityId());
}
Aggregations