Search in sources :

Example 36 with Job

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

the class MultiTenancyTimerStartEventTest method timerStartEventWithTimerCycle.

@Test
public void timerStartEventWithTimerCycle() {
    testRule.deployForTenant(TENANT_ONE, Bpmn.createExecutableProcess().startEvent().timerWithCycle("R2/PT1M").userTask().endEvent().done());
    // execute first timer cycle
    Job job = managementService.createJobQuery().singleResult();
    assertThat(job.getTenantId(), is(TENANT_ONE));
    managementService.executeJob(job.getId());
    // execute second timer cycle
    job = managementService.createJobQuery().singleResult();
    assertThat(job.getTenantId(), is(TENANT_ONE));
    managementService.executeJob(job.getId());
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(2L));
    assertThat(query.withoutTenantId().count(), is(0L));
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 37 with Job

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

the class MultiTenancyTimerStartEventTest method failedJobRetryTimeCycle.

@Test
public void failedJobRetryTimeCycle() {
    testRule.deployForTenant(TENANT_ONE, Bpmn.createExecutableProcess("failingProcess").startEvent().timerWithDuration("PT1M").camundaFailedJobRetryTimeCycle("R5/PT1M").serviceTask().camundaExpression("${failing}").endEvent().done());
    testRule.deployForTenant(TENANT_TWO, Bpmn.createExecutableProcess("failingProcess").startEvent().timerWithDuration("PT1M").camundaFailedJobRetryTimeCycle("R4/PT1M").serviceTask().camundaExpression("${failing}").endEvent().done());
    List<Job> jobs = managementService.createJobQuery().timers().list();
    executeFailingJobs(jobs);
    Job jobTenantOne = managementService.createJobQuery().tenantIdIn(TENANT_ONE).singleResult();
    Job jobTenantTwo = managementService.createJobQuery().tenantIdIn(TENANT_TWO).singleResult();
    assertThat(jobTenantOne.getRetries(), is(4));
    assertThat(jobTenantTwo.getRetries(), is(3));
}
Also used : Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 38 with Job

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

the class MultiTenancyProcessDefinitionSuspensionStateTest method delayedSuspendProcessDefinitionsForNonTenant.

@Test
public void delayedSuspendProcessDefinitionsForNonTenant() {
    // given activated process definitions
    engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().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().withoutTenantId().count(), is(1L));
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 39 with Job

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

the class MultiTenancyProcessDefinitionSuspensionStateTest method delayedSuspendProcessDefinitionsForAllTenants.

@Test
public void delayedSuspendProcessDefinitionsForAllTenants() {
    // given activated process definitions
    engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).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 definitions
    Job job = engineRule.getManagementService().createJobQuery().timers().singleResult();
    assertThat(job, is(notNullValue()));
    engineRule.getManagementService().executeJob(job.getId());
    assertThat(query.active().count(), is(0L));
    assertThat(query.suspended().count(), is(3L));
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 40 with Job

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

the class MultiTenancyProcessDefinitionSuspensionStateTest method delayedActivateProcessDefinitionsForTenant.

@Test
public void delayedActivateProcessDefinitionsForTenant() {
    // given suspended process definitions
    engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    engineRule.getRepositoryService().updateProcessDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).executionDate(tomorrow()).activate();
    ProcessDefinitionQuery query = engineRule.getRepositoryService().createProcessDefinitionQuery();
    assertThat(query.suspended().count(), is(3L));
    assertThat(query.active().count(), is(0L));
    // when execute the job to activate the process definition
    Job job = engineRule.getManagementService().createJobQuery().timers().singleResult();
    assertThat(job, is(notNullValue()));
    engineRule.getManagementService().executeJob(job.getId());
    assertThat(query.suspended().count(), is(2L));
    assertThat(query.active().count(), is(1L));
    assertThat(query.active().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)

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