use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionRestServiceQueryTest method testIncludeJobDefinitionsWithoutTenantIdParameter.
@Test
public void testIncludeJobDefinitionsWithoutTenantIdParameter() {
List<JobDefinition> jobDefinitions = Arrays.asList(MockProvider.mockJobDefinition().tenantId(null).build(), MockProvider.mockJobDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
mockedQuery = setUpMockDefinitionQuery(jobDefinitions);
Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeJobDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(JOB_DEFINITION_QUERY_URL);
verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(mockedQuery).includeJobDefinitionsWithoutTenantId();
verify(mockedQuery).list();
String content = response.asString();
List<String> definitions = from(content).getList("");
assertThat(definitions).hasSize(2);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
assertThat(returnedTenantId1).isEqualTo(null);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testExecuteStandaloneJob.
// execute job (standalone job) ////////////////////////////////
public void testExecuteStandaloneJob() {
// given
createGrantAuthorization(PROCESS_DEFINITION, TIMER_START_PROCESS_KEY, userId, UPDATE);
Date startTime = new Date();
ClockUtil.setCurrentTime(startTime);
long oneWeekFromStartTime = startTime.getTime() + (7 * 24 * 60 * 60 * 1000);
disableAuthorization();
// creates a new "standalone" job
managementService.suspendJobDefinitionByProcessDefinitionKey(TIMER_START_PROCESS_KEY, false, new Date(oneWeekFromStartTime));
enableAuthorization();
String jobId = managementService.createJobQuery().singleResult().getId();
// when
managementService.executeJob(jobId);
// then
JobDefinition jobDefinition = selectJobDefinitionByProcessDefinitionKey(TIMER_START_PROCESS_KEY);
assertTrue(jobDefinition.isSuspended());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionTest method createMonitorJobByQuery.
@Test
public void createMonitorJobByQuery() {
// given
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
Batch batch = historyService.deleteHistoricDecisionInstancesAsync(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);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionTest method createSeedJobByIds.
@Test
public void createSeedJobByIds() {
// when
Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, null);
// then there exists a seed job definition with the batch id as
// configuration
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
assertNotNull(seedJobDefinition);
assertEquals(batch.getId(), seedJobDefinition.getJobConfiguration());
assertEquals(BatchSeedJobHandler.TYPE, seedJobDefinition.getJobType());
// and there exists a deletion job definition
JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
assertNotNull(deletionJobDefinition);
assertEquals(Batch.TYPE_HISTORIC_DECISION_INSTANCE_DELETION, deletionJobDefinition.getJobType());
// and a seed job with no relation to a process or execution etc.
Job seedJob = helper.getSeedJob(batch);
assertNotNull(seedJob);
assertEquals(seedJobDefinition.getId(), seedJob.getJobDefinitionId());
assertNull(seedJob.getDuedate());
assertNull(seedJob.getDeploymentId());
assertNull(seedJob.getProcessDefinitionId());
assertNull(seedJob.getProcessDefinitionKey());
assertNull(seedJob.getProcessInstanceId());
assertNull(seedJob.getExecutionId());
// but no deletion jobs where created
List<Job> deletionJobs = helper.getExecutionJobs(batch);
assertEquals(0, deletionJobs.size());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionTest method createSeedJobByQuery.
@Test
public void createSeedJobByQuery() {
// given
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
// when
Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
// then there exists a seed job definition with the batch id as
// configuration
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
assertNotNull(seedJobDefinition);
assertEquals(batch.getId(), seedJobDefinition.getJobConfiguration());
assertEquals(BatchSeedJobHandler.TYPE, seedJobDefinition.getJobType());
// and there exists a deletion job definition
JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
assertNotNull(deletionJobDefinition);
assertEquals(Batch.TYPE_HISTORIC_DECISION_INSTANCE_DELETION, deletionJobDefinition.getJobType());
// and a seed job with no relation to a process or execution etc.
Job seedJob = helper.getSeedJob(batch);
assertNotNull(seedJob);
assertEquals(seedJobDefinition.getId(), seedJob.getJobDefinitionId());
assertNull(seedJob.getDuedate());
assertNull(seedJob.getDeploymentId());
assertNull(seedJob.getProcessDefinitionId());
assertNull(seedJob.getProcessDefinitionKey());
assertNull(seedJob.getProcessInstanceId());
assertNull(seedJob.getExecutionId());
// but no deletion jobs where created
List<Job> deletionJobs = helper.getExecutionJobs(batch);
assertEquals(0, deletionJobs.size());
}
Aggregations