### Question:
QualityService { QualitySeverityDTO computeQualityOfSeverity(Execution execution, Severity severity, QualityThreshold threshold) { ScenarioCountDTO scenarioCounts = countScenariosOfSeverity(getRunsToIncludeInQuality(execution), severity); int percent = getQualityPercentage(scenarioCounts); QualityStatus severityQualityStatus = (threshold == null ? null : threshold.toStatus(percent)); QualitySeverityDTO qualitySeverity = new QualitySeverityDTO(); qualitySeverity.setSeverity(severityMapper.toDto(severity)); qualitySeverity.setScenarioCounts(scenarioCounts); qualitySeverity.setPercent(percent); qualitySeverity.setStatus(severityQualityStatus); return qualitySeverity; }  void computeQuality(Execution execution);  }### Answer:
@Test public void computeQualityOfSeverity_should_map_severity_to_a_dto() { Execution execution = new Execution(); Severity someSeverity = Severity.ALL; SeverityDTO someSeverityDto = new SeverityDTO(); doReturn(someSeverityDto).when(severityMapper).toDto(someSeverity); QualitySeverityDTO quality = cut.computeQualityOfSeverity(execution, someSeverity, null); assertThat(quality.getSeverity()).isSameAs(someSeverityDto); }
@Test public void computeQualityOfSeverity_should_compute_well() { Execution execution = new Execution() .withRuns(new HashSet<>(Arrays.asList( run() .withIncludeInThresholds(Boolean.TRUE) .withStatus(JobStatus.DONE) .withExecutedScenarios(new HashSet<>(Collections.singletonList( passedScenario().withSeverity("some")))), run() .withIncludeInThresholds(Boolean.TRUE) .withStatus(JobStatus.DONE) .withExecutedScenarios(new HashSet<>(Collections.singletonList( passedScenario().withSeverity("OTHER")))), run() .withIncludeInThresholds(Boolean.FALSE) .withStatus(JobStatus.DONE) .withExecutedScenarios(new HashSet<>(Collections.singletonList( passedScenario().withSeverity("some"))))))); Severity someSeverity = new Severity().withCode("some"); QualityThreshold threshold = new QualityThreshold().withFailure(1).withWarning(1); QualitySeverityDTO quality = cut.computeQualityOfSeverity(execution, someSeverity, threshold); assertThat(quality.getScenarioCounts().getTotal()).isEqualTo(1); assertThat(quality.getPercent()).isEqualTo(100); assertThat(quality.getStatus()).isEqualTo(QualityStatus.PASSED); }