public static IncidentStatisticsResultDto fromIncidentStatistics(IncidentStatistics statistics) { IncidentStatisticsResultDto dto = new IncidentStatisticsResultDto(); dto.setIncidentType(statistics.getIncidentType()); dto.setIncidentCount(statistics.getIncidentCount()); return dto; }
protected void verifyStatisticsResult(ProcessDefinitionStatistics statistics, int instances, int failedJobs, int incidents) { assertEquals("Instances", instances, statistics.getInstances()); assertEquals("Failed Jobs", failedJobs, statistics.getFailedJobs()); List<IncidentStatistics> incidentStatistics = statistics.getIncidentStatistics(); if (incidents == 0) { assertTrue("Incidents supposed to be empty", incidentStatistics.isEmpty()); } else { // the test does have only one type of incidents assertEquals("Incidents", incidents, incidentStatistics.get(0).getIncidentCount()); } }
protected void verifyStatisticsResult(DeploymentStatistics statistics, int instances, int failedJobs, int incidents) { assertEquals("Instances", instances, statistics.getInstances()); assertEquals("Failed Jobs", failedJobs, statistics.getFailedJobs()); List<IncidentStatistics> incidentStatistics = statistics.getIncidentStatistics(); if (incidents == 0) { assertTrue("Incidents supposed to be empty", incidentStatistics.isEmpty()); } else { // the test does have only one type of incidents assertEquals("Incidents", incidents, incidentStatistics.get(0).getIncidentCount()); } }
public static IncidentStatisticsResultDto fromIncidentStatistics(IncidentStatistics statistics) { IncidentStatisticsResultDto dto = new IncidentStatisticsResultDto(); dto.setIncidentType(statistics.getIncidentType()); dto.setIncidentCount(statistics.getIncidentCount()); return dto; }
@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 static List<ActivityStatistics> createMockActivityStatistics() { ActivityStatistics statistics = mock(ActivityStatistics.class); when(statistics.getFailedJobs()).thenReturn(EXAMPLE_FAILED_JOBS); when(statistics.getInstances()).thenReturn(EXAMPLE_INSTANCES); when(statistics.getId()).thenReturn(EXAMPLE_ACTIVITY_ID); IncidentStatistics incidentStaticits = mock(IncidentStatistics.class); when(incidentStaticits.getIncidentType()).thenReturn(EXAMPLE_INCIDENT_TYPE); when(incidentStaticits.getIncidentCount()).thenReturn(EXAMPLE_INCIDENT_COUNT); List<IncidentStatistics> exampleIncidentList = new ArrayList<IncidentStatistics>(); exampleIncidentList.add(incidentStaticits); when(statistics.getIncidentStatistics()).thenReturn(exampleIncidentList); ActivityStatistics anotherStatistics = mock(ActivityStatistics.class); when(anotherStatistics.getFailedJobs()).thenReturn(ANOTHER_EXAMPLE_FAILED_JOBS); when(anotherStatistics.getInstances()).thenReturn(ANOTHER_EXAMPLE_INSTANCES); when(anotherStatistics.getId()).thenReturn(ANOTHER_EXAMPLE_ACTIVITY_ID); IncidentStatistics anotherIncidentStaticits = mock(IncidentStatistics.class); when(anotherIncidentStaticits.getIncidentType()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_TYPE); when(anotherIncidentStaticits.getIncidentCount()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_COUNT); List<IncidentStatistics> anotherExampleIncidentList = new ArrayList<IncidentStatistics>(); anotherExampleIncidentList.add(anotherIncidentStaticits); when(anotherStatistics.getIncidentStatistics()).thenReturn(anotherExampleIncidentList); List<ActivityStatistics> activityResults = new ArrayList<ActivityStatistics>(); activityResults.add(statistics); activityResults.add(anotherStatistics); return activityResults; }
@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()); }
when(incidentStaticits.getIncidentType()).thenReturn(EXAMPLE_INCIDENT_TYPE); when(incidentStaticits.getIncidentCount()).thenReturn(EXAMPLE_INCIDENT_COUNT); when(anotherIncidentStaticits.getIncidentType()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_TYPE); when(anotherIncidentStaticits.getIncidentCount()).thenReturn(ANOTHER_EXAMPLE_INCIDENT_COUNT);
@Test public void incidentsCountWithIncidentTypeAndAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<ProcessDefinitionStatistics> processDefinitionsStatistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidentsForType("failedJob") .list(); // then assertEquals(1, processDefinitionsStatistics.size()); List<IncidentStatistics> incidentStatistics = processDefinitionsStatistics.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.testStatisticsQueryWithFailedJobs.bpmn20.xml"}) public void testDeploymentStatisticsQueryWithIncidents() { 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().list(); assertFalse(statistics.isEmpty()); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); 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 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 @Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml") public void testActivityStatisticsQueryWithIncidentType() { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("fail", true); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ExampleProcess", parameters); executeAvailableJobs(); List<ActivityStatistics> statistics = managementService .createActivityStatisticsQuery(processInstance.getProcessDefinitionId()) .includeIncidentsForType("failedJob") .list(); Assert.assertEquals(1, statistics.size()); ActivityStatistics activityResult = statistics.get(0); List<IncidentStatistics> incidentStatistics = activityResult.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 incidentsCountWithAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); List<ProcessDefinitionStatistics> processDefinitionsStatistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidents() .list(); // then assertEquals(1, processDefinitionsStatistics.size()); List<IncidentStatistics> incidentStatistics = processDefinitionsStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(2, incidentStatistics.get(0).getIncidentCount()); }
@Test @Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testStatisticsQueryWithFailedJobs.bpmn20.xml") public void testActivityStatisticsQueryWithIncidents() { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("fail", true); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("ExampleProcess", parameters); executeAvailableJobs(); List<ActivityStatistics> statistics = managementService .createActivityStatisticsQuery(processInstance.getProcessDefinitionId()) .includeIncidents() .list(); Assert.assertEquals(1, statistics.size()); ActivityStatistics activityResult = statistics.get(0); List<IncidentStatistics> incidentStatistics = activityResult.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 incidentsCountWithMultipleAuthenticatedTenants() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); List<ProcessDefinitionStatistics> processDefinitionsStatistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidents() .list(); // then assertEquals(1, processDefinitionsStatistics.size()); List<IncidentStatistics> incidentStatistics = processDefinitionsStatistics.get(0).getIncidentStatistics(); assertEquals(1, incidentStatistics.size()); assertEquals(3, incidentStatistics.get(0).getIncidentCount()); }
@Deployment(resources = "org/camunda/bpm/engine/test/api/mgmt/StatisticsTest.testFailedTimerStartEvent.bpmn20.xml") public void testQueryByIncidentsWithFailedTimerStartEvent() { executeAvailableJobs(); List<ProcessDefinitionStatistics> statistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidents() .list(); assertEquals(1, statistics.size()); ProcessDefinitionStatistics result = statistics.get(0); // there is no running instance assertEquals(0, result.getInstances()); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); // but there is one incident for the failed timer job assertEquals(1, incidentStatistics.size()); IncidentStatistics incidentStatistic = incidentStatistics.get(0); assertEquals(1, incidentStatistic.getIncidentCount()); assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistic.getIncidentType()); }
@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 testQueryByIncidentTypeWithFailedTimerStartEvent() { executeAvailableJobs(); List<ProcessDefinitionStatistics> statistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidentsForType(Incident.FAILED_JOB_HANDLER_TYPE) .list(); assertEquals(1, statistics.size()); ProcessDefinitionStatistics result = statistics.get(0); // there is no running instance assertEquals(0, result.getInstances()); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); // but there is one incident for the failed timer job assertEquals(1, incidentStatistics.size()); IncidentStatistics incidentStatistic = incidentStatistics.get(0); assertEquals(1, incidentStatistic.getIncidentCount()); assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistic.getIncidentType()); }
@Test public void incidentsCountWithNoAuthenticatedTenant() { testRule.deploy(failingProcess); startProcessInstances(FAILED_JOBS_PROCESS_DEFINITION_KEY); testRule.executeAvailableJobs(); identityService.setAuthentication("user", null, null); List<ProcessDefinitionStatistics> processDefinitionsStatistics = managementService .createProcessDefinitionStatisticsQuery() .includeIncidents() .list(); // then assertEquals(1, processDefinitionsStatistics.size()); List<IncidentStatistics> incidentStatistics = processDefinitionsStatistics.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 testQueryByIncidentsWithFailedTimerStartEvent() { executeAvailableJobs(); List<DeploymentStatistics> statistics = managementService .createDeploymentStatisticsQuery() .includeIncidents() .list(); assertEquals(1, statistics.size()); DeploymentStatistics result = statistics.get(0); // there is no running instance assertEquals(0, result.getInstances()); List<IncidentStatistics> incidentStatistics = result.getIncidentStatistics(); // but there is one incident for the failed timer job assertEquals(1, incidentStatistics.size()); IncidentStatistics incidentStatistic = incidentStatistics.get(0); assertEquals(1, incidentStatistic.getIncidentCount()); assertEquals(Incident.FAILED_JOB_HANDLER_TYPE, incidentStatistic.getIncidentType()); }