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())); }
@Test @Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testCallActivityWithIncidentsWithoutFailedJobs.bpmn20.xml") public void testDeploymentStatisticsQueryWithTwoIncidentsAndOneFailedJobs() { runtimeService.startProcessInstanceByKey("callExampleSubProcess"); executeAvailableJobs(); List<DeploymentStatistics> statistics = managementService .createDeploymentStatisticsQuery() .includeIncidents() .includeFailedJobs() .list(); assertFalse(statistics.isEmpty()); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); // has one failed job Assert.assertEquals(1, result.getFailedJobs()); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); assertFalse(incidentStatistics.isEmpty()); assertEquals(1, incidentStatistics.size()); IncidentStatistics incident = incidentStatistics.get(0); assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType()); assertEquals(2, incident.getIncidentCount()); // ...but two incidents }
@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 testDeploymentStatisticsQueryWithInvalidIncidentType() { 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() .includeIncidentsForType("invalid") .list(); assertFalse(statistics.isEmpty()); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); assertTrue(incidentStatistics.isEmpty()); }
@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 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()); }
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)); }
@Test public void testDeploymentStatisticsQueryCountAndPaging() { org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml") .deploy(); runtimeService.startProcessInstanceByKey("MIExampleProcess"); runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess"); org.camunda.bpm.engine.repository.Deployment anotherDeployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml") .deploy(); runtimeService.startProcessInstanceByKey("MIExampleProcess"); runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess"); long count = managementService.createDeploymentStatisticsQuery().includeFailedJobs().count(); Assert.assertEquals(2, count); List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().listPage(0, 1); Assert.assertEquals(1, statistics.size()); repositoryService.deleteDeployment(deployment.getId(), true); repositoryService.deleteDeployment(anotherDeployment.getId(), true); }
public void testQueryWithReadPermissionOnDeployment() { // given createGrantAuthorization(DEPLOYMENT, firstDeploymentId, userId, READ); // when DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); // then verifyQueryResults(query, 1); DeploymentStatistics statistics = query.singleResult(); 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 incidentsCountWithMultipleAuthenticatedTenants() { 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() .includeIncidents() .list(); // then assertEquals(1, deploymentStatistics.size()); List<IncidentStatistics> incidentStatistics = deploymentStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(3, incidentStatistics.get(0).getIncidentCount()); }
@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 testDeploymentStatisticsQueryCountAndPaging() { org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml") .deploy(); runtimeService.startProcessInstanceByKey("MIExampleProcess"); runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess"); org.camunda.bpm.engine.repository.Deployment anotherDeployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testMultiInstanceStatisticsQuery.bpmn20.xml") .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testParallelGatewayStatisticsQuery.bpmn20.xml") .deploy(); runtimeService.startProcessInstanceByKey("MIExampleProcess"); runtimeService.startProcessInstanceByKey("ParGatewayExampleProcess"); long count = managementService.createDeploymentStatisticsQuery().includeFailedJobs().count(); Assert.assertEquals(2, count); List<DeploymentStatistics> statistics = managementService.createDeploymentStatisticsQuery().includeFailedJobs().listPage(0, 1); Assert.assertEquals(1, statistics.size()); repositoryService.deleteDeployment(deployment.getId(), true); repositoryService.deleteDeployment(anotherDeployment.getId(), true); }
public void testQueryWithReadPermissionOnDeployment() { // given createGrantAuthorization(DEPLOYMENT, firstDeploymentId, userId, READ); // when DeploymentStatisticsQuery query = managementService.createDeploymentStatisticsQuery(); // then verifyQueryResults(query, 1); DeploymentStatistics statistics = query.singleResult(); 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 testDeploymentStatisticsQueryWithIncidentsAndFailedJobs() { 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() .includeIncidents() .includeFailedJobs() .list(); assertFalse(statistics.isEmpty()); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); Assert.assertEquals(1, result.getFailedJobs()); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); assertFalse(incidentStatistics.isEmpty()); assertEquals(1, incidentStatistics.size()); IncidentStatistics incident = incidentStatistics.get(0); assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incident.getIncidentType()); assertEquals(1, incident.getIncidentCount()); }
@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 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()); }
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)); }
@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 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()); }
@Test public void instancesFailedJobsAndIncidentsCountWithAuthenticatedTenant() { testRule.deploy(failingProcess,anotherFailingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); startProcessInstances(ANOTHER_FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<DeploymentStatistics> deploymentStatistics = managementService .createDeploymentStatisticsQuery() .includeFailedJobs() .includeIncidents() .list(); // then assertEquals(1, deploymentStatistics.size()); DeploymentStatistics singleDeploymentStatistics = deploymentStatistics.get(0); assertEquals(4, singleDeploymentStatistics.getInstances()); assertEquals(4, singleDeploymentStatistics.getFailedJobs()); List<IncidentStatistics> incidentStatistics = singleDeploymentStatistics.getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(4, incidentStatistics.get(0).getIncidentCount()); }