Search in sources :

Example 1 with ConditionStatus

use of org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus in project sonarqube by SonarSource.

the class ConditionToCondition method apply.

@Override
@Nonnull
public QualityGate.Condition apply(Condition input) {
    String metricKey = input.getMetric().getKey();
    ConditionStatus conditionStatus = statusPerConditions.get(input);
    checkState(conditionStatus != null, "Missing ConditionStatus for condition on metric key %s", metricKey);
    return builder.setStatus(convert(conditionStatus.getStatus())).setMetricKey(metricKey).setOperator(convert(input.getOperator())).setErrorThreshold(input.getErrorThreshold()).setWarningThreshold(input.getWarningThreshold()).setOnLeakPeriod(input.hasPeriod()).setValue(conditionStatus.getValue()).build();
}
Also used : ConditionStatus(org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus) Nonnull(javax.annotation.Nonnull)

Example 2 with ConditionStatus

use of org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus in project sonarqube by SonarSource.

the class QualityGateMeasuresStep method createStatusPerCondition.

private static Map<Condition, ConditionStatus> createStatusPerCondition(Iterable<Condition> conditions, Iterable<EvaluatedCondition> evaluatedConditions) {
    Map<Condition, EvaluatedCondition> evaluatedConditionPerCondition = from(evaluatedConditions).uniqueIndex(EvaluatedConditionToCondition.INSTANCE);
    ImmutableMap.Builder<Condition, ConditionStatus> builder = ImmutableMap.builder();
    for (Condition condition : conditions) {
        EvaluatedCondition evaluatedCondition = evaluatedConditionPerCondition.get(condition);
        if (evaluatedCondition == null) {
            builder.put(condition, NO_VALUE_STATUS);
        } else {
            builder.put(condition, create(toEvaluationStatus(evaluatedCondition.getLevel()), evaluatedCondition.getActualValue()));
        }
    }
    return builder.build();
}
Also used : EvaluatedCondition(org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition) Condition(org.sonar.server.computation.task.projectanalysis.qualitygate.Condition) EvaluatedCondition(org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition) ConditionStatus(org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ConditionStatus (org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Nonnull (javax.annotation.Nonnull)1 EvaluatedCondition (org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition)1 Condition (org.sonar.server.computation.task.projectanalysis.qualitygate.Condition)1