public void testFailQueryByTenantIdNull() { try { managementService.createJobQuery() .tenantIdIn((String) null); fail("expected exception"); } catch (NullValueException e) { } }
public void testQueryByTenantId() { JobQuery query = managementService .createJobQuery() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); query = managementService .createJobQuery() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); JobQuery query = managementService.createJobQuery(); 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).includeJobsWithoutTenantId().count(), is(2L)); }
public void testQueryByNonExistingTenantId() { JobQuery query = managementService .createJobQuery() .tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
public void testQueryByTenantIds() { JobQuery query = managementService .createJobQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
public void testQuerySortingDesc() { // exclude jobs without tenant id because of database-specific ordering List<Job> jobs = managementService.createJobQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(jobs.size(), is(2)); assertThat(jobs.get(0).getTenantId(), is(TENANT_TWO)); assertThat(jobs.get(1).getTenantId(), is(TENANT_ONE)); }
@Test public void deleteJobsWhileUndeployment() { Deployment deploymentForTenantOne = testRule.deployForTenant(TENANT_ONE, PROCESS); Deployment deploymentForTenantTwo = testRule.deployForTenant(TENANT_TWO, PROCESS); JobQuery query = managementService.createJobQuery(); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantOne.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); repositoryService.deleteDeployment(deploymentForTenantTwo.getId(), true); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
public void testQuerySortingAsc() { // exclude jobs without tenant id because of database-specific ordering List<Job> jobs = managementService.createJobQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(jobs.size(), is(2)); assertThat(jobs.get(0).getTenantId(), is(TENANT_ONE)); assertThat(jobs.get(1).getTenantId(), is(TENANT_TWO)); }
public void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); JobQuery query = managementService.createJobQuery(); 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)); }
@Test public void dontCreateNewJobsWhileReDeployment() { testRule.deployForTenant(TENANT_ONE, PROCESS); testRule.deployForTenant(TENANT_TWO, PROCESS); testRule.deployForTenant(TENANT_ONE, PROCESS); JobQuery query = managementService.createJobQuery(); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
public void testQueryByTenantIdsIncludeJobsWithoutTenantId() { JobQuery query = managementService .createJobQuery() .tenantIdIn(TENANT_ONE) .includeJobsWithoutTenantId(); assertThat(query.count(), is(2L)); query = managementService .createJobQuery() .tenantIdIn(TENANT_TWO) .includeJobsWithoutTenantId(); assertThat(query.count(), is(2L)); query = managementService .createJobQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .includeJobsWithoutTenantId(); assertThat(query.count(), is(3L)); }
@Test public void startProcessInstanceTwoTenants() { testRule.deployForTenant(TENANT_ONE, PROCESS); testRule.deployForTenant(TENANT_TWO, PROCESS); Job jobForTenantOne = managementService.createJobQuery().tenantIdIn(TENANT_ONE).singleResult(); assertThat(jobForTenantOne, is(notNullValue())); managementService.executeJob(jobForTenantOne.getId()); Job jobForTenantTwo = managementService.createJobQuery().tenantIdIn(TENANT_TWO).singleResult(); assertThat(jobForTenantTwo, is(notNullValue())); managementService.executeJob(jobForTenantTwo.getId()); assertThat(runtimeService.createProcessInstanceQuery().tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(runtimeService.createProcessInstanceQuery().tenantIdIn(TENANT_TWO).count(), is(1L)); }
@Test public void suspendJobWithAuthenticatedTenant() { // 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, Arrays.asList(TENANT_ONE)); engineRule.getManagementService() .updateJobSuspensionState() .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)); }
@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)); }
@Test public void suspendJobForTenant() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService() .updateJobSuspensionState() .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)); }
@Test public void suspendJobDefinitionIncludingJobsForTenant() { // given activated job definitions JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .processDefinitionTenantId(TENANT_ONE) .includeJobs(true) .suspend(); assertThat(query.active().count(), is(2L)); assertThat(query.suspended().count(), is(1L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L)); }
@Test public void suspendJobDisabledTenantCheck() { // given activated jobs JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getManagementService() .updateJobSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .suspend(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); assertThat(query.suspended().tenantIdIn(TENANT_ONE, TENANT_TWO).includeJobsWithoutTenantId().count(), is(3L)); }
@Test public void activateProcessInstanceIncludingJobForTenant() { // given suspended job engineRule.getRuntimeService() .updateProcessInstanceSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .suspend(); JobQuery query = engineRule.getManagementService().createJobQuery(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); engineRule.getRuntimeService() .updateProcessInstanceSuspensionState() .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)); }
@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)); }
@Test public void testTenantIdListParameter() { mockQuery = setUpMockJobQuery(createMockJobsTwoTenants()); Response response = given() .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(JOBS_RESOURCE_URL); verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockQuery).list(); String content = response.asString(); List<String> jobs = from(content).getList(""); assertThat(jobs).hasSize(2); String returnedTenantId1 = from(content).getString("[0].tenantId"); String returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }