@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); }
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; }
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; } }
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; }  }
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); }
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);  }