use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTestRule method assertJobMigrated.
public void assertJobMigrated(Job jobBefore, String activityIdAfter, Date dueDateAfter) {
Job jobAfter = snapshotAfterMigration.getJobById(jobBefore.getId());
assertNotNull("Expected that a job with id '" + jobBefore.getId() + "' exists after migration", jobAfter);
JobDefinition jobDefinitionAfter = snapshotAfterMigration.getJobDefinitionForActivityIdAndType(activityIdAfter, ((JobEntity) jobBefore).getJobHandlerType());
assertNotNull("Expected that a job definition for activity '" + activityIdAfter + "' exists after migration", jobDefinitionAfter);
assertEquals(jobBefore.getId(), jobAfter.getId());
assertEquals("Expected that job is assigned to job definition '" + jobDefinitionAfter.getId() + "' after migration", jobDefinitionAfter.getId(), jobAfter.getJobDefinitionId());
assertEquals("Expected that job is assigned to deployment '" + snapshotAfterMigration.getDeploymentId() + "' after migration", snapshotAfterMigration.getDeploymentId(), jobAfter.getDeploymentId());
assertEquals(dueDateAfter, jobAfter.getDuedate());
assertEquals(((JobEntity) jobBefore).getType(), ((JobEntity) jobAfter).getType());
assertEquals(jobBefore.getPriority(), jobAfter.getPriority());
assertEquals(jobDefinitionAfter.getProcessDefinitionId(), jobAfter.getProcessDefinitionId());
assertEquals(jobDefinitionAfter.getProcessDefinitionKey(), jobAfter.getProcessDefinitionKey());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTimerCatchEventTest method testMigrateJobAddParentScope.
@Test
public void testMigrateJobAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.SUBPROCESS_TIMER_CATCH_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("timerCatch", "timerCatch").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertJobMigrated(testHelper.snapshotBeforeMigration.getJobs().get(0), "timerCatch");
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().child("timerCatch").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("timerCatch")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess").activity("timerCatch", testHelper.getSingleActivityInstanceBeforeMigration("timerCatch").getId()).done());
// and it is possible to trigger the event
Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(jobAfterMigration.getId());
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTimerCatchEventTest method testMigrateJobChangeProcessKey.
@Test
public void testMigrateJobChangeProcessKey() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(TimerCatchModels.ONE_TIMER_CATCH_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("timerCatch", "timerCatch").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
testHelper.assertJobMigrated(testHelper.snapshotBeforeMigration.getJobs().get(0), "timerCatch");
// and it is possible to trigger the event
Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(jobAfterMigration.getId());
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTimerCatchEventTest method testMigrateJobUpdateTimerConfiguration.
@Test
public void testMigrateJobUpdateTimerConfiguration() {
// given
ClockTestUtil.setClockToDateWithoutMilliseconds();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(TimerCatchModels.ONE_TIMER_CATCH_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.newModel().startEvent().intermediateCatchEvent("timerCatch").timerWithDuration("PT50M").userTask("userTask").endEvent().done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("timerCatch", "timerCatch").updateEventTrigger().build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
Date newDueDate = new DateTime(ClockUtil.getCurrentTime()).plusMinutes(50).toDate();
testHelper.assertJobMigrated(testHelper.snapshotBeforeMigration.getJobs().get(0), "timerCatch", newDueDate);
// and it is possible to trigger the event
Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(jobAfterMigration.getId());
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class MigrationTransitionInstancesTest method testMigrateAsyncBeforeStartEventTransitionInstanceCase1.
@Test
public void testMigrateAsyncBeforeStartEventTransitionInstanceCase1() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_START_EVENT_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(AsyncProcessModels.ASYNC_BEFORE_START_EVENT_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("startEvent", "startEvent").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertJobMigrated("startEvent", "startEvent", AsyncContinuationJobHandler.TYPE);
// and it is possible to successfully execute the migrated job
Job job = testHelper.snapshotAfterMigration.getJobs().get(0);
Assert.assertEquals("Replace this non-API assert with a proper test case that fails when the wrong atomic operation is used", "process-start", ((JobEntity) job).getJobHandlerConfigurationRaw());
rule.getManagementService().executeJob(job.getId());
// and complete the task and process instance
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Aggregations