use of org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult in project sonarqube by SonarSource.
the class QualityGateMeasuresStep method evaluateQualityGate.
private static MetricEvaluationResult evaluateQualityGate(Measure measure, Collection<Condition> conditions) {
ConditionEvaluator conditionEvaluator = new ConditionEvaluator();
MetricEvaluationResult metricEvaluationResult = null;
for (Condition newCondition : conditions) {
EvaluationResult newEvaluationResult = conditionEvaluator.evaluate(newCondition, measure);
if (metricEvaluationResult == null || newEvaluationResult.getLevel().ordinal() > metricEvaluationResult.evaluationResult.getLevel().ordinal()) {
metricEvaluationResult = new MetricEvaluationResult(newEvaluationResult, newCondition);
}
}
return metricEvaluationResult;
}
use of org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult in project sonarqube by SonarSource.
the class SmallChangesetQualityGateSpecialCaseTest method apply.
@Test
public void apply() {
Comparable<?> value = mock(Comparable.class);
Condition condition = mock(Condition.class);
QualityGateMeasuresStep.MetricEvaluationResult original = new QualityGateMeasuresStep.MetricEvaluationResult(new EvaluationResult(Measure.Level.ERROR, value), condition);
QualityGateMeasuresStep.MetricEvaluationResult modified = underTest.apply(original);
assertThat(modified.evaluationResult.getLevel()).isSameAs(OK);
assertThat(modified.evaluationResult.getValue()).isSameAs(value);
assertThat(modified.condition).isSameAs(condition);
}
use of org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult in project sonarqube by SonarSource.
the class SmallChangesetQualityGateSpecialCaseTest method generateEvaluationResult.
private QualityGateMeasuresStep.MetricEvaluationResult generateEvaluationResult(String metric, Measure.Level level) {
Metric newCoverageMetric = metricRepository.getByKey(metric);
Condition condition = new Condition(newCoverageMetric, "LT", "80");
EvaluationResult evaluationResult = new EvaluationResult(level, mock(Comparable.class));
return new QualityGateMeasuresStep.MetricEvaluationResult(evaluationResult, condition);
}
Aggregations