Search in sources :

Example 41 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class MultiTenancyProcessDefinitionSuspensionStateTest method delayedSuspendProcessDefinitionsForTenant.

@Test
public void delayedSuspendProcessDefinitionsForTenant() {
    // given activated process definitions
    engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).executionDate(tomorrow()).suspend();
    ProcessDefinitionQuery query = engineRule.getRepositoryService().createProcessDefinitionQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    // when execute the job to suspend the process definition
    Job job = engineRule.getManagementService().createJobQuery().timers().singleResult();
    assertThat(job, is(notNullValue()));
    engineRule.getManagementService().executeJob(job.getId());
    assertThat(query.active().count(), is(2L));
    assertThat(query.suspended().count(), is(1L));
    assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 42 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class ProcessInstanceModificationTest method testStartBeforeEventSubscription.

@Deployment(resources = SUBPROCESS_BOUNDARY_EVENTS_PROCESS)
public void testStartBeforeEventSubscription() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess");
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").execute();
    // then two timer jobs should have been created
    assertEquals(2, managementService.createJobQuery().count());
    Job innerJob = managementService.createJobQuery().activityId("innerTimer").singleResult();
    assertNotNull(innerJob);
    assertEquals(runtimeService.createExecutionQuery().activityId("innerTask").singleResult().getId(), innerJob.getExecutionId());
    Job outerJob = managementService.createJobQuery().activityId("outerTimer").singleResult();
    assertNotNull(outerJob);
    // when executing the jobs
    managementService.executeJob(innerJob.getId());
    Task innerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("innerAfterBoundaryTask").singleResult();
    assertNotNull(innerBoundaryTask);
    managementService.executeJob(outerJob.getId());
    Task outerBoundaryTask = taskService.createTaskQuery().taskDefinitionKey("outerAfterBoundaryTask").singleResult();
    assertNotNull(outerBoundaryTask);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class RestartProcessInstanceAsyncTest method testBatchWithFailedExecutionJobDeletionWithCascade.

@Test
public void testBatchWithFailedExecutionJobDeletionWithCascade() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    // when
    Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
    helper.executeSeedJob(batch);
    // create incidents
    List<Job> executionJobs = helper.getExecutionJobs(batch);
    for (Job executionJob : executionJobs) {
        engineRule.getManagementService().setJobRetries(executionJob.getId(), 0);
    }
    engineRule.getManagementService().deleteBatch(batch.getId(), true);
    // then the no historic incidents exists
    long historicIncidents = engineRule.getHistoryService().createHistoricIncidentQuery().count();
    assertEquals(0, historicIncidents);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 44 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class RestartProcessInstanceAsyncTest method testBatchWithFailedSeedJobDeletionWithCascade.

@Test
public void testBatchWithFailedSeedJobDeletionWithCascade() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    // when
    Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).executeAsync();
    // create incident
    Job seedJob = helper.getSeedJob(batch);
    engineRule.getManagementService().setJobRetries(seedJob.getId(), 0);
    engineRule.getManagementService().deleteBatch(batch.getId(), true);
    // then the no historic incidents exists
    long historicIncidents = engineRule.getHistoryService().createHistoricIncidentQuery().count();
    assertEquals(0, historicIncidents);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 45 with Job

use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.

the class RuntimeServiceAsyncOperationsTest method createAndExecuteSeedJobs.

private void createAndExecuteSeedJobs(String seedJobDefinitionId, int expectedSeedJobsCount) {
    for (int i = 0; i <= expectedSeedJobsCount; i++) {
        Job seedJob = managementService.createJobQuery().jobDefinitionId(seedJobDefinitionId).singleResult();
        if (i != expectedSeedJobsCount) {
            assertNotNull(seedJob);
            managementService.executeJob(seedJob.getId());
        } else {
            // the last seed job should not trigger another seed job
            assertNull(seedJob);
        }
    }
}
Also used : Job(org.camunda.bpm.engine.runtime.Job)

Aggregations

Job (org.camunda.bpm.engine.runtime.Job)696 Deployment (org.camunda.bpm.engine.test.Deployment)310 Test (org.junit.Test)232 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)189 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)148 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)135 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)116 HashMap (java.util.HashMap)98 Batch (org.camunda.bpm.engine.batch.Batch)78 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)78 Task (org.camunda.bpm.engine.task.Task)71 Date (java.util.Date)67 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)48 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)24 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)23 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)21 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)20 Incident (org.camunda.bpm.engine.runtime.Incident)17 HistoricJobLog (org.camunda.bpm.engine.history.HistoricJobLog)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)15