Search in sources :

Example 11 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class BatchHistoricDecisionInstanceDeletionTest method createMonitorJobByIdsAndQuery.

@Test
public void createMonitorJobByIdsAndQuery() {
    // given
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
    // 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) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 12 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByIdsAndQuery.

@Test
public void createDeletionJobsByIdsAndQuery() {
    // given
    rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
    ;
    // when
    helper.executeSeedJob(batch);
    // then
    List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
    assertEquals(5, deletionJobs.size());
    for (Job deletionJob : deletionJobs) {
        assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
        assertNull(deletionJob.getDuedate());
        assertNull(deletionJob.getProcessDefinitionId());
        assertNull(deletionJob.getProcessDefinitionKey());
        assertNull(deletionJob.getProcessInstanceId());
        assertNull(deletionJob.getExecutionId());
    }
    // and the seed job still exists
    Job seedJob = helper.getJobForDefinition(seedJobDefinition);
    assertNotNull(seedJob);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 13 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.

the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByQuery.

@Test
public void createDeletionJobsByQuery() {
    // given
    rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(query, null);
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
    ;
    // when
    helper.executeSeedJob(batch);
    // then
    List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
    assertEquals(5, deletionJobs.size());
    for (Job deletionJob : deletionJobs) {
        assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
        assertNull(deletionJob.getDuedate());
        assertNull(deletionJob.getProcessDefinitionId());
        assertNull(deletionJob.getProcessDefinitionKey());
        assertNull(deletionJob.getProcessInstanceId());
        assertNull(deletionJob.getExecutionId());
    }
    // and the seed job still exists
    Job seedJob = helper.getJobForDefinition(seedJobDefinition);
    assertNotNull(seedJob);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 14 with JobDefinition

use of org.camunda.bpm.engine.management.JobDefinition 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");
        }
    }
}
Also used : Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 15 with JobDefinition

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

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