@Test public void getIgnoredScenarioCounts_ShouldComputeAndAggregateIgnoredScenarioCounts_WhenCalled() { final List<SeverityDTO> severities = Arrays.asList( new SeverityDTO().withCode("high").withPosition(Integer.valueOf(1)), new SeverityDTO().withCode("medium").withPosition(Integer.valueOf(2)).withDefaultOnMissing(true), new SeverityDTO().withCode("*").withPosition(Integer.valueOf(3))); when(severityService.getSeveritiesWithAll(PROJECT_ID)).thenReturn(severities); when(severityService.getDefaultSeverityCode(severities)).thenReturn("medium"); final Source sourceA = new Source().withCode("A"); final Source sourceB = new Source().withCode("B"); when(scenarioRepository.findIgnoreCounts(PROJECT_ID)).thenReturn(Arrays.asList( new ScenarioIgnoreCount().withSource(sourceA).withSeverityCode("high").withIgnored(true).withCount(2), new ScenarioIgnoreCount().withSource(sourceA).withSeverityCode("medium").withIgnored(true).withCount(1), new ScenarioIgnoreCount().withSource(sourceA).withSeverityCode("medium").withIgnored(false).withCount(1), new ScenarioIgnoreCount().withSource(sourceB).withSeverityCode("").withIgnored(false).withCount(1))); when(scenarioRepository.findIgnoredScenarios(PROJECT_ID)).thenReturn(Arrays.asList( new IgnoredScenario(sourceA, "f1", "F 1", "high", "Name 1"), new IgnoredScenario(sourceA, "f1", "F 1", "high", "Name 2"), new IgnoredScenario(sourceA, "f2", "F 2", "medium", "Name 3"), new IgnoredScenario(sourceB, "f1", "F 1", "", "Name 4"))); when(sourceMapper.toDto(same(sourceA))).thenReturn(new SourceDTO().withCode("A")); when(sourceMapper.toDto(same(sourceB))).thenReturn(new SourceDTO().withCode("B")); final List<ScenarioIgnoreSourceDTO> result = cut.getIgnoredScenarioCounts(PROJECT_ID); assertThat(result).hasSize(3); assertThat(result.get(0).getSource().getCode()).isEqualTo("*"); assertThat(result.get(0).getSeverities()).hasSize(3); assertThat(result.get(0).getSeverities().get(0).getSeverity().getCode()).isEqualTo("high"); assertThat(result.get(0).getSeverities().get(0).getCounts().getIgnored()).isEqualTo(2); assertThat(result.get(0).getSeverities().get(0).getCounts().getTotal()).isEqualTo(2); assertThat(result.get(0).getSeverities().get(0).getFeatures()).isNull(); assertThat(result.get(0).getSeverities().get(1).getSeverity().getCode()).isEqualTo("medium"); assertThat(result.get(0).getSeverities().get(1).getCounts().getIgnored()).isEqualTo(1); assertThat(result.get(0).getSeverities().get(1).getCounts().getTotal()).isEqualTo(3); assertThat(result.get(0).getSeverities().get(1).getFeatures()).isNull(); assertThat(result.get(0).getSeverities().get(2).getSeverity().getCode()).isEqualTo("*"); assertThat(result.get(0).getSeverities().get(2).getCounts().getIgnored()).isEqualTo(3); assertThat(result.get(0).getSeverities().get(2).getCounts().getTotal()).isEqualTo(5); assertThat(result.get(0).getSeverities().get(2).getFeatures()).isNull(); assertThat(result.get(1).getSource().getCode()).isEqualTo("A"); assertThat(result.get(1).getSeverities()).hasSize(3); assertThat(result.get(1).getSeverities().get(0).getSeverity().getCode()).isEqualTo("high"); assertThat(result.get(1).getSeverities().get(0).getCounts().getIgnored()).isEqualTo(2); assertThat(result.get(1).getSeverities().get(0).getCounts().getTotal()).isEqualTo(2); assertThat(result.get(1).getSeverities().get(0).getFeatures()).hasSize(1); assertThat(result.get(1).getSeverities().get(0).getFeatures().get(0).getName()).isEqualTo("F 1"); assertThat(result.get(1).getSeverities().get(0).getFeatures().get(0).getFile()).isEqualTo("f1"); assertThat(result.get(1).getSeverities().get(0).getFeatures().get(0).getScenarios()).hasSize(2); assertThat(result.get(1).getSeverities().get(0).getFeatures().get(0).getScenarios().get(0)).isEqualTo("Name 1"); assertThat(result.get(1).getSeverities().get(0).getFeatures().get(0).getScenarios().get(1)).isEqualTo("Name 2"); assertThat(result.get(1).getSeverities().get(1).getSeverity().getCode()).isEqualTo("medium"); assertThat(result.get(1).getSeverities().get(1).getCounts().getIgnored()).isEqualTo(1); assertThat(result.get(1).getSeverities().get(1).getCounts().getTotal()).isEqualTo(2); assertThat(result.get(1).getSeverities().get(1).getFeatures()).hasSize(1); assertThat(result.get(1).getSeverities().get(1).getFeatures().get(0).getName()).isEqualTo("F 2"); assertThat(result.get(1).getSeverities().get(1).getFeatures().get(0).getFile()).isEqualTo("f2"); assertThat(result.get(1).getSeverities().get(1).getFeatures().get(0).getScenarios()).hasSize(1); assertThat(result.get(1).getSeverities().get(1).getFeatures().get(0).getScenarios().get(0)).isEqualTo("Name 3"); assertThat(result.get(1).getSeverities().get(2).getSeverity().getCode()).isEqualTo("*"); assertThat(result.get(1).getSeverities().get(2).getCounts().getIgnored()).isEqualTo(3); assertThat(result.get(1).getSeverities().get(2).getCounts().getTotal()).isEqualTo(4); assertThat(result.get(1).getSeverities().get(2).getFeatures()).isNull(); assertThat(result.get(2).getSource().getCode()).isEqualTo("B"); assertThat(result.get(2).getSeverities()).hasSize(2); }
public List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId) { List<SeverityDTO> severitiesWithAll = severityService.getSeveritiesWithAll(projectId); String defaultSeverityCode = severityService.getDefaultSeverityCode(severitiesWithAll); List<ScenarioIgnoreSourceDTO> resultList = new ArrayList<>(); fillCountsInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); fillScenariosInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); addGlobalSource(resultList); sort(resultList); return resultList; }
ScenarioService { public List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId) { List<SeverityDTO> severitiesWithAll = severityService.getSeveritiesWithAll(projectId); String defaultSeverityCode = severityService.getDefaultSeverityCode(severitiesWithAll); List<ScenarioIgnoreSourceDTO> resultList = new ArrayList<>(); fillCountsInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); fillScenariosInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); addGlobalSource(resultList); sort(resultList); return resultList; } }
ScenarioService { public List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId) { List<SeverityDTO> severitiesWithAll = severityService.getSeveritiesWithAll(projectId); String defaultSeverityCode = severityService.getDefaultSeverityCode(severitiesWithAll); List<ScenarioIgnoreSourceDTO> resultList = new ArrayList<>(); fillCountsInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); fillScenariosInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); addGlobalSource(resultList); sort(resultList); return resultList; }  }
ScenarioService { public List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId) { List<SeverityDTO> severitiesWithAll = severityService.getSeveritiesWithAll(projectId); String defaultSeverityCode = severityService.getDefaultSeverityCode(severitiesWithAll); List<ScenarioIgnoreSourceDTO> resultList = new ArrayList<>(); fillCountsInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); fillScenariosInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); addGlobalSource(resultList); sort(resultList); return resultList; }  List<ScenarioSummaryDTO> findAllWithFunctionalityErrors(long projectId); List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId); }
ScenarioService { public List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId) { List<SeverityDTO> severitiesWithAll = severityService.getSeveritiesWithAll(projectId); String defaultSeverityCode = severityService.getDefaultSeverityCode(severitiesWithAll); List<ScenarioIgnoreSourceDTO> resultList = new ArrayList<>(); fillCountsInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); fillScenariosInto(projectId, resultList, severitiesWithAll, defaultSeverityCode); addGlobalSource(resultList); sort(resultList); return resultList; }  List<ScenarioSummaryDTO> findAllWithFunctionalityErrors(long projectId); List<ScenarioIgnoreSourceDTO> getIgnoredScenarioCounts(long projectId);  }