Search in sources :

Example 16 with Condition

use of org.sonar.server.computation.task.projectanalysis.qualitygate.Condition 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 : PERIOD_ORDERING.immutableSortedCopy(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.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition) Condition(org.sonar.server.computation.task.projectanalysis.qualitygate.Condition) ConditionEvaluator(org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionEvaluator) EvaluationResult(org.sonar.server.computation.task.projectanalysis.qualitygate.EvaluationResult)

Aggregations

Condition (org.sonar.server.computation.task.projectanalysis.qualitygate.Condition)16 Test (org.junit.Test)11 EvaluatedCondition (org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition)10 Measure (org.sonar.server.computation.task.projectanalysis.measure.Measure)8 QualityGate (org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGate)7 QualityGateDetailsData (org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.QualityGateDetailsData)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 Metric (org.sonar.server.computation.task.projectanalysis.metric.Metric)2 JsonObject (com.google.gson.JsonObject)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 Collection (java.util.Collection)1 Map (java.util.Map)1 QualityGate (org.sonar.api.ce.posttask.QualityGate)1 QualityGateStatus (org.sonar.server.computation.task.projectanalysis.measure.QualityGateStatus)1 MetricImpl (org.sonar.server.computation.task.projectanalysis.metric.MetricImpl)1 ConditionEvaluator (org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionEvaluator)1 ConditionStatus (org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus)1 EvaluationResult (org.sonar.server.computation.task.projectanalysis.qualitygate.EvaluationResult)1