### Question:
ExecutionHistoryService { void fillQualities(List<ExecutedScenarioWithErrorAndProblemJoin> allExecutedScenarioJoin, RunWithQualitiesDTO run, Map<Long, Long> functionalityTeamIds, String defaultSeverityCode) { run.setQualitiesPerSeverity(new HashMap<>()); run.setQualitiesPerTeamAndSeverity(new HashMap<>()); final List<ExecutedScenarioWithErrorAndProblemJoin> allExecutedScenarioJoinOfRun = allExecutedScenarioJoin .stream() .filter(e -> run.getId().longValue() == e.getRunId()) .collect(Collectors.toList()); for (ExecutedScenarioWithErrorAndProblemJoin executedScenarioJoin : allExecutedScenarioJoinOfRun) { addScenario(executedScenarioJoin, run.getQualitiesPerSeverity(), defaultSeverityCode); final List<Long> functionalityIds = ScenarioExtractorUtil .extractFunctionalityIds(executedScenarioJoin.getName()); final Set<Long> teamIds = functionalityIds.stream() .map(functionalityTeamIds::get) .filter(Objects::nonNull) .collect(Collectors.toSet()); if (teamIds.isEmpty()) { addScenarioForTeamAndSeverity(run, defaultSeverityCode, executedScenarioJoin, Team.NOT_ASSIGNED.getId()); } for (Long teamId : teamIds) { addScenarioForTeamAndSeverity(run, defaultSeverityCode, executedScenarioJoin, teamId); } } }  List<ExecutionHistoryPointDTO> getLatestExecutionHistories(long projectId); ExecutionHistoryPointDTO getExecution(long projectId, long id); ExecutedScenarioHandlingCountsDTO getExecutedScenarioHandlingCountsFor(Execution execution);  }### Answer:
@Test public void fillQualities_should_fill_qualitiesPerSeverity_and_qualitiesPerTeamAndSeverity() { final Long runId = Long.valueOf(8); RunWithQualitiesDTO run = new RunWithQualitiesDTO(); run.setId(runId); String defaultSeverityCode = "medium"; Map<Long, Long> functionalityTeamIds = new HashMap<>(); functionalityTeamIds.put(Long.valueOf(1), Long.valueOf(11)); List<ExecutedScenarioWithErrorAndProblemJoin> allErrorCounts = Arrays.asList( new ExecutedScenarioWithErrorAndProblemJoin(111, runId.longValue(), "medium", "Functionality 1: A Title", 1, 0), new ExecutedScenarioWithErrorAndProblemJoin(112, runId.longValue(), "medium", "No functionality => no team", 1, 0), new ExecutedScenarioWithErrorAndProblemJoin(111, 404, "medium", "From another run", 1, 0)); cut.fillQualities(allErrorCounts, run, functionalityTeamIds, defaultSeverityCode); assertThat(run.getQualitiesPerSeverity().get("medium").getTotal()).isEqualTo(2); assertThat(run.getQualitiesPerSeverity().get("*").getTotal()).isEqualTo(2); assertThat(run.getQualitiesPerTeamAndSeverity().get("11").get("medium").getTotal()).isEqualTo(1); assertThat(run.getQualitiesPerTeamAndSeverity().get("11").get("*").getTotal()).isEqualTo(1); assertThat(run.getQualitiesPerTeamAndSeverity().get("-404").get("medium").getTotal()).isEqualTo(1); assertThat(run.getQualitiesPerTeamAndSeverity().get("-404").get("*").getTotal()).isEqualTo(1); }