Search in sources :

Example 91 with JobDefinition

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);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 92 with JobDefinition

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);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 93 with JobDefinition

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());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 94 with JobDefinition

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());
}
Also used : JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 95 with JobDefinition

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());
}
Also used : JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Aggregations

JobDefinition (org.camunda.bpm.engine.management.JobDefinition)219 Job (org.camunda.bpm.engine.runtime.Job)135 Deployment (org.camunda.bpm.engine.test.Deployment)112 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)86 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)73 HashMap (java.util.HashMap)67 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)64 Test (org.junit.Test)63 Batch (org.camunda.bpm.engine.batch.Batch)28 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)16 Date (java.util.Date)11 InputStream (java.io.InputStream)8 Deployment (org.camunda.bpm.engine.repository.Deployment)8 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)8 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)6 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)4 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)4 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 Response (com.jayway.restassured.response.Response)2