Search in sources :

Example 1 with EvaluationResult

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;
}
Also used : EvaluatedCondition(org.sonar.ce.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition) Condition(org.sonar.ce.task.projectanalysis.qualitygate.Condition) ConditionEvaluator(org.sonar.ce.task.projectanalysis.qualitygate.ConditionEvaluator) EvaluationResult(org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult)

Example 2 with EvaluationResult

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);
}
Also used : Condition(org.sonar.ce.task.projectanalysis.qualitygate.Condition) EvaluationResult(org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult) Test(org.junit.Test)

Example 3 with EvaluationResult

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);
}
Also used : Condition(org.sonar.ce.task.projectanalysis.qualitygate.Condition) Metric(org.sonar.ce.task.projectanalysis.metric.Metric) EvaluationResult(org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult)

Aggregations

Condition (org.sonar.ce.task.projectanalysis.qualitygate.Condition)3 EvaluationResult (org.sonar.ce.task.projectanalysis.qualitygate.EvaluationResult)3 Test (org.junit.Test)1 EvaluatedCondition (org.sonar.ce.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition)1 Metric (org.sonar.ce.task.projectanalysis.metric.Metric)1 ConditionEvaluator (org.sonar.ce.task.projectanalysis.qualitygate.ConditionEvaluator)1