public void testQueryByDefinitionsWithoutTenantIds() { JobDefinitionQuery query = managementService .createJobDefinitionQuery() .withoutTenantId(); assertThat(query.count(), is(1L)); }
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)); }
@Test public void testWithoutTenantIdPostParameter() { Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("withoutTenantId", true); Response response = given() .contentType(POST_JSON_CONTENT_TYPE) .body(queryParameters) .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(JOB_DEFINITION_QUERY_URL); verify(mockedQuery).withoutTenantId(); verify(mockedQuery).list(); String content = response.asString(); List<String> jobs = from(content).getList(""); assertThat(jobs).hasSize(1); String returnedTenantId = from(content).getString("[0].tenantId"); assertThat(returnedTenantId).isEqualTo(null); }
@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)); }
@Test public void suspendProcessDefinitionIncludingJobDefinitionsForNonTenant() { // given activated jobs JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getRepositoryService() .updateProcessDefinitionSuspensionState() .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)); }
@Test public void testWithoutTenantIdParameter() { Response response = given() .queryParam("withoutTenantId", true) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(JOB_DEFINITION_QUERY_URL); verify(mockedQuery).withoutTenantId(); verify(mockedQuery).list(); String content = response.asString(); List<String> jobs = from(content).getList(""); assertThat(jobs).hasSize(1); String returnedTenantId = from(content).getString("[0].tenantId"); assertThat(returnedTenantId).isEqualTo(null); }
@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)); }
@Test public void suspendJobDefinitionNoAuthenticatedTenants() { // 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, null); engineRule.getManagementService() .updateJobDefinitionSuspensionState() .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)); }
@Test public void delayedSuspendJobDefinitionsForNonTenant() { // given activated job definitions engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .processDefinitionWithoutTenantId() .executionDate(tomorrow()) .suspend(); JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); // when execute the job to suspend the job definitions 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)); }
@Test public void jobProcessDefinitionForNonTenant() { // given suspend job definitions engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .suspend(); JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.suspended().count(), is(3L)); assertThat(query.active().count(), is(0L)); engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .processDefinitionWithoutTenantId() .activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().withoutTenantId().count(), is(1L)); }
@Test public void activateProcessDefinitionIncludingJobDefinitionsForNonTenant() { // given suspended jobs engineRule.getRepositoryService() .updateProcessDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .suspend(); JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); engineRule.getRepositoryService() .updateProcessDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .processDefinitionWithoutTenantId() .activate(); assertThat(query.suspended().count(), is(2L)); assertThat(query.active().count(), is(1L)); assertThat(query.active().withoutTenantId().count(), is(1L)); }
@Test public void delayedActivateJobDefinitionsForNonTenant() { // given suspend job definitions engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .suspend(); engineRule.getManagementService() .updateJobDefinitionSuspensionState() .byProcessDefinitionKey(PROCESS_DEFINITION_KEY) .processDefinitionWithoutTenantId() .executionDate(tomorrow()) .activate(); JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.active().count(), is(0L)); assertThat(query.suspended().count(), is(3L)); // when execute the job to activate the job definitions 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().withoutTenantId().count(), is(1L)); }
public void testQueryByDefinitionsWithoutTenantIds() { JobDefinitionQuery query = managementService .createJobDefinitionQuery() .withoutTenantId(); assertThat(query.count(), is(1L)); }
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)); }
@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)); }
@Test public void suspendProcessDefinitionIncludingJobDefinitionsForNonTenant() { // given activated jobs JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery(); assertThat(query.active().count(), is(3L)); assertThat(query.suspended().count(), is(0L)); engineRule.getRepositoryService() .updateProcessDefinitionSuspensionState() .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)); }
@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)); }
@Test public void suspendJobDefinitionNoAuthenticatedTenants() { // 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, null); engineRule.getManagementService() .updateJobDefinitionSuspensionState() .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)); }