public void testQueryNoAuthenticatedTenantsForDeploymentStatistics() { identityService.setAuthentication("user", null, null); DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); assertThat(query.count(), is(1L)); Set<String> tenantIds = collectDeploymentTenantIds(query.list()); assertThat(tenantIds.size(), is(1)); assertThat(tenantIds.iterator().next(), is(nullValue())); }
public void testDeploymentStatistics() { List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .list(); assertThat(deploymentStatistics.size(), is(3)); Set<String> tenantIds = collectDeploymentTenantIds(deploymentStatistics); assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO)); }
public void testQueryAuthenticatedTenantForDeploymentStatistics() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); assertThat(query.count(), is(2L)); Set<String> tenantIds = collectDeploymentTenantIds(query.list()); assertThat(tenantIds.size(), is(2)); assertThat(tenantIds, hasItems(null, TENANT_ONE)); }
public void testQueryAuthenticatedTenantsForDeploymentStatistics() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); assertThat(query.count(), is(3L)); Set<String> tenantIds = collectDeploymentTenantIds(query.list()); assertThat(tenantIds.size(), is(3)); assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO)); }
@Test public void activeProcessInstancesCountWithAuthenticatedTenant() { testRule.deploy(oneTaskProcess); startProcessInstances(ONE_TASK_PROCESS_DEFINITION_KEY); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .list(); // then assertEquals(1, deploymentStatistics.size()); // user can see the process instances that belongs to tenant1 and instances that have no tenant assertEquals(2, deploymentStatistics.get(0).getInstances()); }
@Test public void activeProcessInstancesCountWithMultipleAuthenticatedTenants() { testRule.deploy(oneTaskProcess); startProcessInstances(ONE_TASK_PROCESS_DEFINITION_KEY); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .list(); // then assertEquals(1, deploymentStatistics.size()); // user can see all the active process instances assertEquals(3, deploymentStatistics.get(0).getInstances()); }
public void testQueryDisabledTenantCheckForDeploymentStatistics() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); assertThat(query.count(), is(3L)); Set<String> tenantIds = collectDeploymentTenantIds(query.list()); assertThat(tenantIds.size(), is(3)); assertThat(tenantIds, hasItems(null, TENANT_ONE, TENANT_TWO)); }
public void testQueryWithReadPermissionOnAnyDeployment() { // given createGrantAuthorization(DEPLOYMENT, ANY, userId, READ); // when DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); // then verifyQueryResults(query, 3); List<DeploymentStatistics> result = query.list(); for (DeploymentStatistics statistics : result) { verifyStatisticsResult(statistics, 0, 0, 0); } }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml"}) public void testDeploymentStatisticsQueryWithFailedJobs() { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("fail", true); runtimeService.startProcessInstanceByKey("MIExampleProcess"); runtimeService.startProcessInstanceByKey("ExampleProcess", parameters); executeAvailableJobs(); List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().list(); DeploymentStatistics result = statistics.get(0); Assert.assertEquals(1, result.getFailedJobs()); }
@Test public void activeProcessInstancesCountWithNoAuthenticatedTenant() { testRule.deploy(oneTaskProcess); startProcessInstances(ONE_TASK_PROCESS_DEFINITION_KEY); identityService.setAuthentication("user", null, null); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .list(); // then assertEquals(1, deploymentStatistics.size()); // user must see only the process instances that belongs to no tenant assertEquals(1, deploymentStatistics.get(0).getInstances()); }
@Test public void incidentsCountWithIncidentTypeAndAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeIncidentsForType("failedJob") .list(); // then assertEquals(1, deploymentStatistics.size()); List<IncidentStatistics> incidentStatistics = deploymentStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(2, incidentStatistics.get(0).getIncidentCount()); }
@Test public void incidentsCountWithAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeIncidents() .list(); // then assertEquals(1, deploymentStatistics.size()); List<IncidentStatistics> incidentStatistics = deploymentStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(2, incidentStatistics.get(0).getIncidentCount()); }
@Test @Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml", "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml"}) public void testDeploymentStatisticsQueryWithoutRunningInstances() { List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().list(); Assert.assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); Assert.assertEquals(0, result.getInstances()); Assert.assertEquals(0, result.getFailedJobs()); }
@Test public void failedJobsCountWithAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .list(); // then assertEquals(1, deploymentStatistics.size()); assertEquals(2, deploymentStatistics.get(0).getFailedJobs()); }
@Test public void failedJobsCountWithMultipleAuthenticatedTenants() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .list(); // then assertEquals(1, deploymentStatistics.size()); assertEquals(3, deploymentStatistics.get(0).getFailedJobs()); }
@Test public void activeProcessInstancesCountWithDisabledTenantCheck() { testRule.deploy(oneTaskProcess); startProcessInstances(ONE_TASK_PROCESS_DEFINITION_KEY); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .list(); // then assertEquals(1, deploymentStatistics.size()); assertEquals(3, deploymentStatistics.get(0).getInstances()); }
@Test public void incidentsCountWithNoAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, null); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeIncidents() .list(); // then assertEquals(1, deploymentStatistics.size()); List<IncidentStatistics> incidentStatistics = deploymentStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(1, incidentStatistics.get(0).getIncidentCount()); }
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml") public void testQueryByFailedJobsWithFailedTimerStartEvent() { executeAvailableJobs(); List<DeploymentStatistics> statistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .list(); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); // there is no running instance assertEquals(0, result.getInstances()); // but there is one failed timer job assertEquals(1, result.getFailedJobs()); }
@Test public void failedJobsCountWithWithNoAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, null); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .list(); // then assertEquals(1, deploymentStatistics.size()); assertEquals(1, deploymentStatistics.get(0).getFailedJobs()); }
@Test public void failedJobsCountWithWithDisabledTenantCheck() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .list(); // then assertEquals(1, deploymentStatistics.size()); assertEquals(3, deploymentStatistics.get(0).getFailedJobs()); }