@Test public void aggregateQualitiesPerTeamAndSeverity_should_aggregate_team_qualities() { final String SEVERITY_1 = "severity1"; final String SEVERITY_2 = "severity2"; final String SEVERITY_3 = "severity3"; final String SEVERITY_ALL = "*"; Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> quality1 = new HashMap<>(); { Map<String, ExecutedScenarioHandlingCountsDTO> quality1team1 = new HashMap<>(); quality1team1.put(SEVERITY_1, new ExecutedScenarioHandlingCountsDTO(1, 2, 3)); quality1team1.put(SEVERITY_2, new ExecutedScenarioHandlingCountsDTO(0, 0, 1)); quality1team1.put(SEVERITY_ALL, new ExecutedScenarioHandlingCountsDTO(1, 2, 4)); quality1.put("1", quality1team1); } { Map<String, ExecutedScenarioHandlingCountsDTO> quality1team2 = new HashMap<>(); quality1team2.put(SEVERITY_1, new ExecutedScenarioHandlingCountsDTO(3, 2, 0)); quality1team2.put(SEVERITY_ALL, new ExecutedScenarioHandlingCountsDTO(3, 2, 0)); quality1.put("2", quality1team2); } Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> quality2 = new HashMap<>(); { Map<String, ExecutedScenarioHandlingCountsDTO> quality2team1 = new HashMap<>(); quality2team1.put(SEVERITY_2, new ExecutedScenarioHandlingCountsDTO(0, 0, 1)); quality2team1.put(SEVERITY_ALL, new ExecutedScenarioHandlingCountsDTO(0, 0, 1)); quality2.put("1", quality2team1); } { quality2.put("2", new HashMap<>()); } Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> quality3 = new HashMap<>(); { Map<String, ExecutedScenarioHandlingCountsDTO> quality3team1 = new HashMap<>(); quality3team1.put(SEVERITY_3, new ExecutedScenarioHandlingCountsDTO(0, 1, 0)); quality3team1.put(SEVERITY_ALL, new ExecutedScenarioHandlingCountsDTO(0, 1, 0)); quality3.put("2", quality3team1); } ExecutionHistoryPointDTO execution = new ExecutionHistoryPointDTO() .withRuns(Arrays.asList( new RunWithQualitiesDTO().withQualitiesPerTeamAndSeverity(quality1), new RunWithQualitiesDTO().withQualitiesPerTeamAndSeverity(quality2), new RunWithQualitiesDTO().withQualitiesPerTeamAndSeverity(quality3))); final Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregatedQualities = cut.aggregateQualitiesPerTeamAndSeverity(execution); assertThat(aggregatedQualities).containsOnlyKeys("1", "2"); assertThat(aggregatedQualities.get("1")).containsOnlyKeys(SEVERITY_1, SEVERITY_2, SEVERITY_ALL); assertThat(aggregatedQualities.get("1").get(SEVERITY_1)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(1, 2, 3)); assertThat(aggregatedQualities.get("1").get(SEVERITY_2)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(0, 0, 2)); assertThat(aggregatedQualities.get("1").get(SEVERITY_ALL)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(1, 2, 5)); assertThat(aggregatedQualities.get("2")).containsOnlyKeys(SEVERITY_1, SEVERITY_3, SEVERITY_ALL); assertThat(aggregatedQualities.get("2").get(SEVERITY_1)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(3, 2, 0)); assertThat(aggregatedQualities.get("2").get(SEVERITY_3)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(0, 1, 0)); assertThat(aggregatedQualities.get("2").get(SEVERITY_ALL)).isEqualTo(new ExecutedScenarioHandlingCountsDTO(3, 3, 0)); }
Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregateQualitiesPerTeamAndSeverity(ExecutionHistoryPointDTO execution) { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> globalRunQualities = new HashMap<>(); execution.getRuns().forEach(run -> run.getQualitiesPerTeamAndSeverity().forEach((teamId, runQualities) -> runQualities.forEach((severityCode, counts) -> { final Map<String, ExecutedScenarioHandlingCountsDTO> foundCounts = globalRunQualities.computeIfAbsent(teamId, k -> new HashMap<>()); final ExecutedScenarioHandlingCountsDTO foundCount = foundCounts.computeIfAbsent(severityCode, k -> new ExecutedScenarioHandlingCountsDTO()); foundCount.add(counts); }) ) ); return globalRunQualities; }
QualityEmailService { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregateQualitiesPerTeamAndSeverity(ExecutionHistoryPointDTO execution) { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> globalRunQualities = new HashMap<>(); execution.getRuns().forEach(run -> run.getQualitiesPerTeamAndSeverity().forEach((teamId, runQualities) -> runQualities.forEach((severityCode, counts) -> { final Map<String, ExecutedScenarioHandlingCountsDTO> foundCounts = globalRunQualities.computeIfAbsent(teamId, k -> new HashMap<>()); final ExecutedScenarioHandlingCountsDTO foundCount = foundCounts.computeIfAbsent(severityCode, k -> new ExecutedScenarioHandlingCountsDTO()); foundCount.add(counts); }) ) ); return globalRunQualities; } }
QualityEmailService { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregateQualitiesPerTeamAndSeverity(ExecutionHistoryPointDTO execution) { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> globalRunQualities = new HashMap<>(); execution.getRuns().forEach(run -> run.getQualitiesPerTeamAndSeverity().forEach((teamId, runQualities) -> runQualities.forEach((severityCode, counts) -> { final Map<String, ExecutedScenarioHandlingCountsDTO> foundCounts = globalRunQualities.computeIfAbsent(teamId, k -> new HashMap<>()); final ExecutedScenarioHandlingCountsDTO foundCount = foundCounts.computeIfAbsent(severityCode, k -> new ExecutedScenarioHandlingCountsDTO()); foundCount.add(counts); }) ) ); return globalRunQualities; }  }
QualityEmailService { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregateQualitiesPerTeamAndSeverity(ExecutionHistoryPointDTO execution) { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> globalRunQualities = new HashMap<>(); execution.getRuns().forEach(run -> run.getQualitiesPerTeamAndSeverity().forEach((teamId, runQualities) -> runQualities.forEach((severityCode, counts) -> { final Map<String, ExecutedScenarioHandlingCountsDTO> foundCounts = globalRunQualities.computeIfAbsent(teamId, k -> new HashMap<>()); final ExecutedScenarioHandlingCountsDTO foundCount = foundCounts.computeIfAbsent(severityCode, k -> new ExecutedScenarioHandlingCountsDTO()); foundCount.add(counts); }) ) ); return globalRunQualities; }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId); }
QualityEmailService { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> aggregateQualitiesPerTeamAndSeverity(ExecutionHistoryPointDTO execution) { Map<String, Map<String, ExecutedScenarioHandlingCountsDTO>> globalRunQualities = new HashMap<>(); execution.getRuns().forEach(run -> run.getQualitiesPerTeamAndSeverity().forEach((teamId, runQualities) -> runQualities.forEach((severityCode, counts) -> { final Map<String, ExecutedScenarioHandlingCountsDTO> foundCounts = globalRunQualities.computeIfAbsent(teamId, k -> new HashMap<>()); final ExecutedScenarioHandlingCountsDTO foundCount = foundCounts.computeIfAbsent(severityCode, k -> new ExecutedScenarioHandlingCountsDTO()); foundCount.add(counts); }) ) ); return globalRunQualities; }  @Transactional(readOnly = true, noRollbackFor = Exception.class) void sendQualityEmail(long projectId, long executionId);  }