Search in sources :

Example 6 with JobDefinition

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);
}
Also used : Response(com.jayway.restassured.response.Response) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 7 with JobDefinition

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());
}
Also used : Date(java.util.Date) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 8 with JobDefinition

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);
}
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 9 with JobDefinition

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());
}
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 10 with JobDefinition

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());
}
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)

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