Search in sources :

Example 6 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionQueryTest method testQueryAuthenticatedTenant.

public void testQueryAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    JobDefinitionQuery query = managementService.createJobDefinitionQuery();
    assertThat(query.count(), is(2L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L));
    assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobDefinitionsWithoutTenantId().count(), is(2L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery)

Example 7 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionQueryTest method testQueryAuthenticatedTenants.

public void testQueryAuthenticatedTenants() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));
    JobDefinitionQuery query = managementService.createJobDefinitionQuery();
    assertThat(query.count(), is(3L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L));
    assertThat(query.withoutTenantId().count(), is(1L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery)

Example 8 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionSuspensionStateTest method suspendJobDefinitionWithAuthenticatedTenant.

@Test
public void suspendJobDefinitionWithAuthenticatedTenant() {
    // given activated job definitions
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    engineRule.getIdentityService().setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    engineRule.getIdentityService().clearAuthentication();
    assertThat(query.active().count(), is(1L));
    assertThat(query.suspended().count(), is(2L));
    assertThat(query.active().tenantIdIn(TENANT_TWO).count(), is(1L));
    assertThat(query.suspended().withoutTenantId().count(), is(1L));
    assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) Test(org.junit.Test)

Example 9 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionSuspensionStateTest method suspendJobDefinitionForNonTenant.

@Test
public void suspendJobDefinitionForNonTenant() {
    // given activated job definitions
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionWithoutTenantId().suspend();
    assertThat(query.active().count(), is(2L));
    assertThat(query.suspended().count(), is(1L));
    assertThat(query.suspended().withoutTenantId().count(), is(1L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) Test(org.junit.Test)

Example 10 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionSuspensionStateTest method suspendAndActivateJobDefinitionsForAllTenants.

@Test
public void suspendAndActivateJobDefinitionsForAllTenants() {
    // given activated job definitions
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
    // first suspend
    engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
    assertThat(query.active().count(), is(0L));
    assertThat(query.suspended().count(), is(3L));
    // then activate
    engineRule.getManagementService().updateJobDefinitionSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).activate();
    assertThat(query.active().count(), is(3L));
    assertThat(query.suspended().count(), is(0L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) Test(org.junit.Test)

Aggregations

JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)163 Deployment (org.camunda.bpm.engine.test.Deployment)89 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)88 HashMap (java.util.HashMap)86 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)86 Job (org.camunda.bpm.engine.runtime.Job)78 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)54 Test (org.junit.Test)31 Date (java.util.Date)12 InputStream (java.io.InputStream)10 Deployment (org.camunda.bpm.engine.repository.Deployment)10 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 ArrayList (java.util.ArrayList)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 JobDefinitionDto (org.camunda.bpm.engine.rest.dto.management.JobDefinitionDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Matchers.anyString (org.mockito.Matchers.anyString)1