Search in sources :

Example 11 with EvaluatedQualityGate

use of org.sonar.server.qualitygate.EvaluatedQualityGate in project sonarqube by SonarSource.

the class QualityGateHolderImplTest method getEvaluation_returns_QualityGate_set_by_setQualityGate.

@Test
public void getEvaluation_returns_QualityGate_set_by_setQualityGate() {
    QualityGateHolderImpl holder = new QualityGateHolderImpl();
    EvaluatedQualityGate evaluation = mock(EvaluatedQualityGate.class);
    holder.setEvaluation(evaluation);
    assertThat(holder.getEvaluation().get()).isSameAs(evaluation);
}
Also used : EvaluatedQualityGate(org.sonar.server.qualitygate.EvaluatedQualityGate) Test(org.junit.Test)

Example 12 with EvaluatedQualityGate

use of org.sonar.server.qualitygate.EvaluatedQualityGate in project sonarqube by SonarSource.

the class QGToEvaluatedQG method apply.

@Override
public EvaluatedQualityGate apply(QualityGate qg) {
    EvaluatedQualityGate.Builder builder = EvaluatedQualityGate.newBuilder();
    Set<Condition> conditions = qg.getConditions().stream().map(q -> {
        Condition condition = new Condition(q.getMetricKey(), Condition.Operator.valueOf(q.getOperator().name()), q.getErrorThreshold());
        builder.addEvaluatedCondition(condition, EvaluatedCondition.EvaluationStatus.valueOf(q.getStatus().name()), q.getStatus() == EvaluationStatus.NO_VALUE ? null : q.getValue());
        return condition;
    }).collect(MoreCollectors.toSet());
    return builder.setQualityGate(new org.sonar.server.qualitygate.QualityGate(qg.getId(), qg.getName(), conditions)).setStatus(Metric.Level.valueOf(qg.getStatus().name())).build();
}
Also used : EvaluatedCondition(org.sonar.server.qualitygate.EvaluatedCondition) Condition(org.sonar.server.qualitygate.Condition) EvaluatedCondition(org.sonar.server.qualitygate.EvaluatedCondition) QualityGate(org.sonar.api.ce.posttask.QualityGate) EvaluationStatus(org.sonar.api.ce.posttask.QualityGate.EvaluationStatus) EvaluatedQualityGate(org.sonar.server.qualitygate.EvaluatedQualityGate) Set(java.util.Set) Function(java.util.function.Function) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) Metric(org.sonar.api.measures.Metric) Condition(org.sonar.server.qualitygate.Condition) EvaluatedQualityGate(org.sonar.server.qualitygate.EvaluatedQualityGate)

Aggregations

EvaluatedQualityGate (org.sonar.server.qualitygate.EvaluatedQualityGate)12 QualityGate (org.sonar.server.qualitygate.QualityGate)8 Test (org.junit.Test)7 Condition (org.sonar.server.qualitygate.Condition)6 EvaluatedCondition (org.sonar.server.qualitygate.EvaluatedCondition)5 Metric (org.sonar.api.measures.Metric)3 ComponentDto (org.sonar.db.component.ComponentDto)3 MetricDto (org.sonar.db.metric.MetricDto)3 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Supplier (java.util.function.Supplier)2 QualityGate (org.sonar.api.ce.posttask.QualityGate)2 Configuration (org.sonar.api.config.Configuration)2 BranchDto (org.sonar.db.component.BranchDto)2 LiveMeasureDto (org.sonar.db.measure.LiveMeasureDto)2 ProjectDto (org.sonar.db.project.ProjectDto)2 QualityGateEvaluator (org.sonar.server.qualitygate.QualityGateEvaluator)2 Analysis (org.sonar.server.webhook.Analysis)2 Collection (java.util.Collection)1