Search in sources :

Example 16 with JobQuery

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

the class MultiTenancyJobSuspensionStateTest method suspendJobNoAuthenticatedTenants.

@Test
public void suspendJobNoAuthenticatedTenants() {
    // given activated jobs
    JobQuery query = engineRule.getManagementService().createJobQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    engineRule.getIdentityService().setAuthentication("user", null, null);
    engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    engineRule.getIdentityService().clearAuthentication();
    assertThat(query.active().count(), is(2L));
    assertThat(query.suspended().count(), is(1L));
    assertThat(query.suspended().withoutTenantId().count(), is(1L));
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Test(org.junit.Test)

Example 17 with JobQuery

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

the class MultiTenancyJobSuspensionStateTest method activateJobsForTenant.

@Test
public void activateJobsForTenant() {
    // given suspend jobs
    engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    JobQuery query = engineRule.getManagementService().createJobQuery();
    assertThat(query.suspended().count(), is(3L));
    assertThat(query.active().count(), is(0L));
    engineRule.getManagementService().updateJobSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).activate();
    assertThat(query.suspended().count(), is(2L));
    assertThat(query.active().count(), is(1L));
    assertThat(query.active().tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Test(org.junit.Test)

Example 18 with JobQuery

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

the class MultiTenancyProcessInstanceSuspensionStateTest method suspendProcessInstanceIncludingJobForNonTenant.

@Test
public void suspendProcessInstanceIncludingJobForNonTenant() {
    // given activated jobs
    JobQuery query = engineRule.getManagementService().createJobQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().suspend();
    assertThat(query.active().count(), is(2L));
    assertThat(query.suspended().count(), is(1L));
    assertThat(query.suspended().singleResult().getTenantId(), is(nullValue()));
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Test(org.junit.Test)

Example 19 with JobQuery

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

the class MultiTenancyProcessInstanceSuspensionStateTest method suspendAndActivateProcessInstancesIncludingJobsForAllTenants.

@Test
public void suspendAndActivateProcessInstancesIncludingJobsForAllTenants() {
    // given activated jobs
    JobQuery query = engineRule.getManagementService().createJobQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    // first suspend
    engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    assertThat(query.active().count(), is(0L));
    assertThat(query.suspended().count(), is(3L));
    // then activate
    engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).activate();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Test(org.junit.Test)

Example 20 with JobQuery

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

the class MultiTenancyProcessInstanceSuspensionStateTest method suspendProcessInstanceIncludingJobForTenant.

@Test
public void suspendProcessInstanceIncludingJobForTenant() {
    // given activated jobs
    JobQuery query = engineRule.getManagementService().createJobQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionTenantId(TENANT_ONE).suspend();
    assertThat(query.active().count(), is(2L));
    assertThat(query.suspended().count(), is(1L));
    assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Test(org.junit.Test)

Aggregations

JobQuery (org.camunda.bpm.engine.runtime.JobQuery)255 Deployment (org.camunda.bpm.engine.test.Deployment)143 Job (org.camunda.bpm.engine.runtime.Job)115 HashMap (java.util.HashMap)105 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)88 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)73 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)55 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)41 Test (org.junit.Test)32 Date (java.util.Date)30 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)23 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)17 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)14 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 Task (org.camunda.bpm.engine.task.Task)8 Batch (org.camunda.bpm.engine.batch.Batch)5 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)5 ActivitySequenceCounterMap (org.camunda.bpm.engine.test.standalone.entity.ExecutionOrderListener.ActivitySequenceCounterMap)5 Matchers.anyString (org.mockito.Matchers.anyString)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3