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