From: Julien Lancelot Date: Tue, 7 Feb 2017 10:53:47 +0000 (+0100) Subject: SONAR-8743 Handle only leak period when computing quality gate measure X-Git-Tag: 6.3-RC1~93 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d64f1a2a3596e5d61f2f656f3ec1e4f285443fad;p=sonarqube.git SONAR-8743 Handle only leak period when computing quality gate measure --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToCondition.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToCondition.java index 161e52841e7..1782af68294 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToCondition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToCondition.java @@ -43,7 +43,7 @@ class ConditionToCondition implements Function @Override @Nonnull - public QualityGate.Condition apply(@Nonnull Condition input) { + 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); @@ -53,7 +53,7 @@ class ConditionToCondition implements Function .setOperator(convert(input.getOperator())) .setErrorThreshold(input.getErrorThreshold()) .setWarningThreshold(input.getWarningThreshold()) - .setOnLeakPeriod(input.getPeriod() != null) + .setOnLeakPeriod(input.hasPeriod()) .setValue(conditionStatus.getValue()) .build(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsData.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsData.java index 95f99ec1691..e2286b8b372 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsData.java @@ -58,8 +58,8 @@ public class QualityGateDetailsData { JsonObject result = new JsonObject(); result.addProperty("metric", condition.getMetric().getKey()); result.addProperty("op", condition.getOperator().getDbValue()); - if (condition.getPeriod() != null) { - result.addProperty("period", condition.getPeriod()); + if (condition.hasPeriod()) { + result.addProperty("period", 1); } if (condition.getWarningThreshold() != null) { result.addProperty("warning", condition.getWarningThreshold()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/Condition.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/Condition.java index 4415e306633..4ccef65e2a0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/Condition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/Condition.java @@ -51,15 +51,14 @@ public class Condition { private final String warningThreshold; @CheckForNull private final String errorThreshold; - @CheckForNull - private final Integer period; + private final boolean hasPeriod; public Condition(Metric metric, String operator, @Nullable String errorThreshold, @Nullable String warningThreshold, - @Nullable Integer period) { + boolean hasPeriod) { this.metric = requireNonNull(metric); this.operator = parseFromDbValue(requireNonNull(operator)); - this.period = period; + this.hasPeriod = hasPeriod; this.errorThreshold = errorThreshold; this.warningThreshold = warningThreshold; } @@ -77,9 +76,8 @@ public class Condition { return metric; } - @CheckForNull - public Integer getPeriod() { - return period; + public boolean hasPeriod() { + return hasPeriod; } public Operator getOperator() { @@ -106,19 +104,19 @@ public class Condition { } Condition that = (Condition) o; return java.util.Objects.equals(metric, that.metric) - && java.util.Objects.equals(period, that.period); + && java.util.Objects.equals(hasPeriod, that.hasPeriod); } @Override public int hashCode() { - return hash(metric, period); + return hash(metric, hasPeriod); } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("metric", metric) - .add("period", period) + .add("hasPeriod", hasPeriod) .add("operator", operator) .add("warningThreshold", warningThreshold) .add("errorThreshold", errorThreshold) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluator.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluator.java index 612ec285dad..33fd138212c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluator.java @@ -23,7 +23,6 @@ import java.util.Optional; import javax.annotation.CheckForNull; import org.apache.commons.lang.StringUtils; import org.sonar.server.computation.task.projectanalysis.measure.Measure; -import org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations; import org.sonar.server.computation.task.projectanalysis.metric.Metric; import static com.google.common.base.Preconditions.checkArgument; @@ -31,8 +30,6 @@ import static java.util.Optional.of; public final class ConditionEvaluator { - private static final Optional NO_PERIOD_VALUE = Optional.empty(); - /** * Evaluates the condition for the specified measure */ @@ -118,7 +115,7 @@ public final class ConditionEvaluator { @CheckForNull private static Comparable parseMeasure(Condition condition, Measure measure) { - if (condition.getPeriod() != null) { + if (condition.hasPeriod()) { return parseMeasureFromVariation(condition, measure); } switch (measure.getValueType()) { @@ -144,7 +141,7 @@ public final class ConditionEvaluator { @CheckForNull private static Comparable parseMeasureFromVariation(Condition condition, Measure measure) { - Optional periodValue = getPeriodValue(measure, condition.getPeriod()); + Optional periodValue = getPeriodValue(measure); if (periodValue.isPresent()) { switch (condition.getMetric().getType().getValueType()) { case BOOLEAN: @@ -165,26 +162,8 @@ public final class ConditionEvaluator { return null; } - private static Optional getPeriodValue(Measure measure, int period) { - if (!measure.hasVariations()) { - return Optional.empty(); - } - - MeasureVariations variations = measure.getVariations(); - switch (period) { - case 1: - return variations.hasVariation1() ? of(variations.getVariation1()) : NO_PERIOD_VALUE; - case 2: - return variations.hasVariation2() ? of(variations.getVariation2()) : NO_PERIOD_VALUE; - case 3: - return variations.hasVariation3() ? of(variations.getVariation3()) : NO_PERIOD_VALUE; - case 4: - return variations.hasVariation4() ? of(variations.getVariation4()) : NO_PERIOD_VALUE; - case 5: - return variations.hasVariation5() ? of(variations.getVariation5()) : NO_PERIOD_VALUE; - default: - throw new IllegalArgumentException("Following index period is not allowed : " + period); - } + private static Optional getPeriodValue(Measure measure) { + return measure.hasVariation() ? Optional.of(measure.getVariation()) : Optional.empty(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterImpl.java index 9b91fac65c0..04c6d0fc1be 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterImpl.java @@ -68,13 +68,13 @@ public final class EvaluationResultTextConverterImpl implements EvaluationResult } private String getAlertLabel(Condition condition, Measure.Level level) { - Integer alertPeriod = condition.getPeriod(); + boolean hasPeriod = condition.hasPeriod(); String metric = i18n.message(Locale.ENGLISH, "metric." + condition.getMetric().getKey() + ".name", condition.getMetric().getName()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(metric); - if (alertPeriod != null && !condition.getMetric().getKey().startsWith(VARIATION_METRIC_PREFIX)) { + if (hasPeriod && !condition.getMetric().getKey().startsWith(VARIATION_METRIC_PREFIX)) { String variation = i18n.message(Locale.ENGLISH, VARIATION, VARIATION).toLowerCase(Locale.ENGLISH); stringBuilder.append(" ").append(variation); } @@ -83,8 +83,8 @@ public final class EvaluationResultTextConverterImpl implements EvaluationResult .append(" ").append(OPERATOR_LABELS.get(condition.getOperator())).append(" ") .append(alertValue(condition, level)); - if (alertPeriod != null) { - Period period = periodsHolder.getPeriod(alertPeriod); + if (hasPeriod) { + Period period = periodsHolder.getPeriod(); stringBuilder.append(" ").append(periods.label(period.getMode(), period.getModeParameter(), DateUtils.longToDate(period.getSnapshotDate()))); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java index 6cb78b36ba5..1706935566b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java @@ -40,7 +40,7 @@ public class QualityGateServiceImpl implements QualityGateService { this.conditionDao = conditionDao; this.conditionDtoToBean = (QualityGateConditionDto input) -> { Metric metric = metricRepository.getById(input.getMetricId()); - return new Condition(metric, input.getOperator(), input.getErrorThreshold(), input.getWarningThreshold(), input.getPeriod()); + return new Condition(metric, input.getOperator(), input.getErrorThreshold(), input.getWarningThreshold(), input.getPeriod() != null); }; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java index e377f1d1d78..6b323070887 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStep.java @@ -33,6 +33,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.measures.CoreMetrics; +import org.sonar.core.util.stream.Collectors; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit; import org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler; @@ -73,8 +74,8 @@ import static org.sonar.server.computation.task.projectanalysis.qualitygate.Cond * It must be executed after the computation of differential measures {@link ComputeMeasureVariationsStep} */ public class QualityGateMeasuresStep implements ComputationStep { - private static final Ordering PERIOD_ORDERING = Ordering.natural().nullsLast() - .onResultOf(ConditionToPeriod.INSTANCE); + // Condition on period should come first + private static final Ordering PERIOD_ORDERING = Ordering.natural().reverse().onResultOf(Condition::hasPeriod); private final TreeRootHolder treeRootHolder; private final QualityGateHolder qualityGateHolder; @@ -170,7 +171,7 @@ public class QualityGateMeasuresStep implements ComputationStep { } private void updateMeasures(Component project, Set conditions, QualityGateDetailsDataBuilder builder) { - Multimap conditionsPerMetric = from(conditions).index(ConditionToMetric.INSTANCE); + Multimap conditionsPerMetric = conditions.stream().collect(Collectors.index(Condition::getMetric, java.util.function.Function.identity())); for (Map.Entry> entry : conditionsPerMetric.asMap().entrySet()) { Metric metric = entry.getKey(); Optional measure = measureRepository.getRawMeasure(project, metric); @@ -277,23 +278,4 @@ public class QualityGateMeasuresStep implements ComputationStep { } } - private enum ConditionToMetric implements Function { - INSTANCE; - - @Override - @Nonnull - public Metric apply(@Nonnull Condition input) { - return input.getMetric(); - } - } - - public enum ConditionToPeriod implements Function { - INSTANCE; - - @Override - @Nullable - public Integer apply(@Nonnull Condition input) { - return input.getPeriod(); - } - } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToConditionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToConditionTest.java index 3532024fab7..39a58207c82 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToConditionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/ConditionToConditionTest.java @@ -46,7 +46,7 @@ public class ConditionToConditionTest { private static final Map NO_STATUS_PER_CONDITIONS = Collections.emptyMap(); private static final String SOME_VALUE = "some value"; private static final ConditionStatus SOME_CONDITION_STATUS = ConditionStatus.create(ConditionStatus.EvaluationStatus.OK, SOME_VALUE); - private static final Condition SOME_CONDITION = new Condition(newMetric(METRIC_KEY), Condition.Operator.EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, 1); + private static final Condition SOME_CONDITION = new Condition(newMetric(METRIC_KEY), Condition.Operator.EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, true); @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -98,7 +98,7 @@ public class ConditionToConditionTest { @Test @UseDataProvider("allOperatorValues") public void apply_converts_all_values_of_operator(Condition.Operator operator) { - Condition condition = new Condition(newMetric(METRIC_KEY), operator.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, 1); + Condition condition = new Condition(newMetric(METRIC_KEY), operator.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, true); ConditionToCondition underTest = new ConditionToCondition(of(condition, SOME_CONDITION_STATUS)); assertThat(underTest.apply(condition).getOperator().name()).isEqualTo(operator.name()); @@ -106,7 +106,7 @@ public class ConditionToConditionTest { @Test public void apply_sets_onLeakPeriod_flag_when_Condition_has_non_null_Period() { - Condition noPeriodCondition = new Condition(newMetric(METRIC_KEY), Condition.Operator.NOT_EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, null); + Condition noPeriodCondition = new Condition(newMetric(METRIC_KEY), Condition.Operator.NOT_EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, false); ConditionToCondition underTest = new ConditionToCondition(of( SOME_CONDITION, SOME_CONDITION_STATUS, noPeriodCondition, SOME_CONDITION_STATUS)); @@ -117,11 +117,10 @@ public class ConditionToConditionTest { @Test public void apply_copies_value() { - Condition otherCondition = new Condition(newMetric(METRIC_KEY), Condition.Operator.NOT_EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, null); + Condition otherCondition = new Condition(newMetric(METRIC_KEY), Condition.Operator.NOT_EQUALS.getDbValue(), ERROR_THRESHOLD, WARN_THRESHOLD, false); ConditionToCondition underTest = new ConditionToCondition(of( - SOME_CONDITION, SOME_CONDITION_STATUS, - otherCondition, ConditionStatus.NO_VALUE_STATUS - )); + SOME_CONDITION, SOME_CONDITION_STATUS, + otherCondition, ConditionStatus.NO_VALUE_STATUS)); assertThat(underTest.apply(SOME_CONDITION).getValue()).isEqualTo(SOME_VALUE); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java index cc76771d2da..67758a9ae99 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java @@ -271,7 +271,7 @@ public class PostProjectAnalysisTasksExecutorTest { private static Condition createCondition(String metricKey) { Metric metric = mock(Metric.class); when(metric.getKey()).thenReturn(metricKey); - return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), "error threshold", "warn threshold", null); + return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), "error threshold", "warn threshold", false); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/EvaluatedConditionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/EvaluatedConditionTest.java index 7491f588d68..36f854909e1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/EvaluatedConditionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/EvaluatedConditionTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock; public class EvaluatedConditionTest { - private static final Condition SOME_CONDITION = new Condition(mock(Metric.class), Condition.Operator.EQUALS.getDbValue(), "1", null, null); + private static final Condition SOME_CONDITION = new Condition(mock(Metric.class), Condition.Operator.EQUALS.getDbValue(), "1", null, false); private static final Measure.Level SOME_LEVEL = Measure.Level.OK; private static final String SOME_VALUE = "some value"; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsDataTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsDataTest.java index ca78ef7b02c..b99a00ef227 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsDataTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/qualitygatedetails/QualityGateDetailsDataTest.java @@ -44,53 +44,52 @@ public class QualityGateDetailsDataTest { String actualJson = new QualityGateDetailsData(Measure.Level.OK, Collections.emptyList()).toJson(); JsonAssert.assertJson(actualJson).isSimilarTo("{" + - "\"level\":\"OK\"," + - "\"conditions\":[]" + - "}"); + "\"level\":\"OK\"," + + "\"conditions\":[]" + + "}"); } @Test public void verify_json_for_each_type_of_condition() { String value = "actualValue"; - Condition condition = new Condition(new MetricImpl(1, "key1", "name1", Metric.MetricType.STRING), Condition.Operator.GREATER_THAN.getDbValue(), "errorTh", "warnTh", 10); + Condition condition = new Condition(new MetricImpl(1, "key1", "name1", Metric.MetricType.STRING), Condition.Operator.GREATER_THAN.getDbValue(), "errorTh", "warnTh", true); ImmutableList evaluatedConditions = ImmutableList.of( - new EvaluatedCondition(condition, Measure.Level.OK, value), - new EvaluatedCondition(condition, Measure.Level.WARN, value), - new EvaluatedCondition(condition, Measure.Level.ERROR, value) - ); + new EvaluatedCondition(condition, Measure.Level.OK, value), + new EvaluatedCondition(condition, Measure.Level.WARN, value), + new EvaluatedCondition(condition, Measure.Level.ERROR, value)); String actualJson = new QualityGateDetailsData(Measure.Level.OK, evaluatedConditions).toJson(); JsonAssert.assertJson(actualJson).isSimilarTo("{" + - "\"level\":\"OK\"," + - "\"conditions\":[" + - " {" + - " \"metric\":\"key1\"," + - " \"op\":\"GT\"," + - " \"period\":10," + - " \"warning\":\"warnTh\"," + - " \"error\":\"errorTh\"," + - " \"actual\":\"actualValue\"," + - " \"level\":\"OK\"" + - " }," + - " {" + - " \"metric\":\"key1\"," + - " \"op\":\"GT\"," + - " \"period\":10," + - " \"warning\":\"warnTh\"," + - " \"error\":\"errorTh\"," + - " \"actual\":\"actualValue\"," + - " \"level\":\"WARN\"" + - " }," + - " {" + - " \"metric\":\"key1\"," + - " \"op\":\"GT\"," + - " \"period\":10," + - " \"warning\":\"warnTh\"," + - " \"error\":\"errorTh\"," + - " \"actual\":\"actualValue\"," + - " \"level\":\"ERROR\"" + - " }" + - "]" + - "}"); + "\"level\":\"OK\"," + + "\"conditions\":[" + + " {" + + " \"metric\":\"key1\"," + + " \"op\":\"GT\"," + + " \"period\":1," + + " \"warning\":\"warnTh\"," + + " \"error\":\"errorTh\"," + + " \"actual\":\"actualValue\"," + + " \"level\":\"OK\"" + + " }," + + " {" + + " \"metric\":\"key1\"," + + " \"op\":\"GT\"," + + " \"period\":1," + + " \"warning\":\"warnTh\"," + + " \"error\":\"errorTh\"," + + " \"actual\":\"actualValue\"," + + " \"level\":\"WARN\"" + + " }," + + " {" + + " \"metric\":\"key1\"," + + " \"op\":\"GT\"," + + " \"period\":1," + + " \"warning\":\"warnTh\"," + + " \"error\":\"errorTh\"," + + " \"actual\":\"actualValue\"," + + " \"level\":\"ERROR\"" + + " }" + + "]" + + "}"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluatorTest.java index c60f3518c9d..457d3fd3e29 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionEvaluatorTest.java @@ -25,7 +25,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.server.computation.task.projectanalysis.measure.Measure; -import org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations; import org.sonar.server.computation.task.projectanalysis.metric.Metric; import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl; @@ -242,8 +241,8 @@ public class ConditionEvaluatorTest { assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "10.2"), measure)).hasLevel(ERROR); assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "10.1"), measure)).hasLevel(OK); - assertThat(underTest.evaluate(new Condition(metric, EQUALS.getDbValue(), "10.3", "10.2", null), measure)).hasLevel(Measure.Level.WARN); - assertThat(underTest.evaluate(new Condition(metric, LESS_THAN.getDbValue(), "10.3", "10.2", null), measure)).hasLevel(Measure.Level.ERROR); + assertThat(underTest.evaluate(new Condition(metric, EQUALS.getDbValue(), "10.3", "10.2", false), measure)).hasLevel(Measure.Level.WARN); + assertThat(underTest.evaluate(new Condition(metric, LESS_THAN.getDbValue(), "10.3", "10.2", false), measure)).hasLevel(Measure.Level.ERROR); } @Test @@ -271,34 +270,18 @@ public class ConditionEvaluatorTest { public void test_condition_on_period() { for (MetricType metricType : ImmutableList.of(FLOAT, INT, WORK_DUR)) { Metric metric = createMetric(metricType); - Measure measure = newMeasureBuilder().setVariations(new MeasureVariations(null, 3d, 4d, null, null)).createNoValue(); + Measure measure = newMeasureBuilder().setVariation(3d).createNoValue(); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 2), measure)).hasLevel(OK); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, 2), measure)).hasLevel(ERROR); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, 3), measure)).hasLevel(OK); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 3), measure)).hasLevel(ERROR); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, true), measure)).hasLevel(OK); } } @Test public void condition_on_period_without_value_is_OK() { Metric metric = createMetric(FLOAT); - Measure measure = newMeasureBuilder().setVariations(new MeasureVariations(null, 3d, 4d, null, null)).createNoValue(); + Measure measure = newMeasureBuilder().createNoValue(); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 1), measure)).hasLevel(OK).hasValue(null); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 4), measure)).hasLevel(OK); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 5), measure)).hasLevel(OK); - } - - @Test - public void evaluate_throws_IAE_if_condition_is_on_invalid_period() { - Metric metric = createMetric(FLOAT); - Measure measure = newMeasureBuilder().setVariations(new MeasureVariations(null, 3d, 4d, null, null)).createNoValue(); - - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Following index period is not allowed : 50"); - - underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, 50), measure); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, true), measure)).hasLevel(OK).hasValue(null); } @Test @@ -306,29 +289,29 @@ public class ConditionEvaluatorTest { Metric metric = createMetric(RATING); Measure measure = newMeasureBuilder().create(4, "D"); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, null), measure)).hasLevel(OK).hasValue(4); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, null), measure)).hasLevel(ERROR).hasValue(4); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, false), measure)).hasLevel(OK).hasValue(4); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, false), measure)).hasLevel(ERROR).hasValue(4); } @Test public void test_condition_on_rating_on_leak_period() throws Exception { Metric metric = createMetric(RATING); - Measure measure = newMeasureBuilder().setVariations(new MeasureVariations(4d, null, null, null, null)).createNoValue(); + Measure measure = newMeasureBuilder().setVariation(4d).createNoValue(); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "5", null, 1), measure)).hasLevel(OK).hasValue(4); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, 1), measure)).hasLevel(ERROR).hasValue(4); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "5", null, true), measure)).hasLevel(OK).hasValue(4); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, true), measure)).hasLevel(ERROR).hasValue(4); } @Test public void test_condition_on_rating_on_leak_period_when_variation_is_zero() throws Exception { Metric metric = createMetric(RATING); - Measure measure = newMeasureBuilder().setVariations(new MeasureVariations(0d, null, null, null, null)).createNoValue(); + Measure measure = newMeasureBuilder().setVariation(0d).createNoValue(); - assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, 1), measure)).hasLevel(OK).hasValue(0); + assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, true), measure)).hasLevel(OK).hasValue(0); } private static Condition createErrorCondition(Metric metric, Condition.Operator operator, String errorThreshold) { - return new Condition(metric, operator.getDbValue(), errorThreshold, null, null); + return new Condition(metric, operator.getDbValue(), errorThreshold, null, false); } private static MetricImpl createMetric(MetricType metricType) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionTest.java index 715aaada646..68b67879703 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/ConditionTest.java @@ -38,12 +38,12 @@ public class ConditionTest { @Test(expected = NullPointerException.class) public void constructor_throws_NPE_for_null_metric_argument() { - new Condition(null, SOME_OPERATOR, null, null, null); + new Condition(null, SOME_OPERATOR, null, null, false); } @Test(expected = NullPointerException.class) public void constructor_throws_NPE_for_null_operator_argument() { - new Condition(SOME_METRIC, null, null, null, null); + new Condition(SOME_METRIC, null, null, null, false); } @Test @@ -51,20 +51,19 @@ public class ConditionTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Unsupported operator value: 'troloto'"); - new Condition(SOME_METRIC, "troloto", null, null, null); + new Condition(SOME_METRIC, "troloto", null, null, false); } @Test public void verify_getters() { - Integer period = 1; String error = "error threshold"; String warning = "warning threshold"; - Condition condition = new Condition(SOME_METRIC, SOME_OPERATOR, error, warning, period); + Condition condition = new Condition(SOME_METRIC, SOME_OPERATOR, error, warning, true); assertThat(condition.getMetric()).isSameAs(SOME_METRIC); assertThat(condition.getOperator()).isSameAs(Condition.Operator.EQUALS); - assertThat(condition.getPeriod()).isEqualTo(period); + assertThat(condition.hasPeriod()).isTrue(); assertThat(condition.getErrorThreshold()).isEqualTo(error); assertThat(condition.getWarningThreshold()).isEqualTo(warning); } @@ -73,8 +72,8 @@ public class ConditionTest { public void all_fields_are_displayed_in_toString() { when(SOME_METRIC.toString()).thenReturn("metric1"); - assertThat(new Condition(SOME_METRIC, SOME_OPERATOR, "error_l", "warn", 1).toString()) - .isEqualTo("Condition{metric=metric1, period=1, operator=EQUALS, warningThreshold=warn, errorThreshold=error_l}"); + assertThat(new Condition(SOME_METRIC, SOME_OPERATOR, "error_l", "warn", true).toString()) + .isEqualTo("Condition{metric=metric1, hasPeriod=true, operator=EQUALS, warningThreshold=warn, errorThreshold=error_l}"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterTest.java index b63bf02ef20..cafe1266e0e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/EvaluationResultTextConverterTest.java @@ -49,7 +49,7 @@ import static org.sonar.server.computation.task.projectanalysis.measure.Measure. public class EvaluationResultTextConverterTest { private static final Metric INT_METRIC = new MetricImpl(1, "key", "int_metric_name", Metric.MetricType.INT); private static final Metric SOME_VARIATION_METRIC = new MetricImpl(2, "new_variation_of_trololo", "variation_of_trololo_name", Metric.MetricType.INT); - private static final Condition EQ_10_CONDITION = new Condition(INT_METRIC, Condition.Operator.EQUALS.getDbValue(), "10", null, null); + private static final Condition EQ_10_CONDITION = new Condition(INT_METRIC, Condition.Operator.EQUALS.getDbValue(), "10", null, false); private static final EvaluationResult OK_EVALUATION_RESULT = new EvaluationResult(Measure.Level.OK, null); private static final String ERROR_THRESHOLD = "error_threshold"; private static final String WARNING_THRESHOLD = "warning_threshold"; @@ -98,7 +98,7 @@ public class EvaluationResultTextConverterTest { when(i18n.message(Locale.ENGLISH, "metric." + INT_METRIC.getKey() + ".name", INT_METRIC.getName())) .thenReturn(metricMsg); - Condition condition = new Condition(INT_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, null); + Condition condition = new Condition(INT_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, false); assertThat(underTest.asText(condition, new EvaluationResult(level, null))) .isEqualTo(metricMsg + " " + toSign(operator) + " " + getThreshold(level)); @@ -116,7 +116,7 @@ public class EvaluationResultTextConverterTest { when(i18n.message(Locale.ENGLISH, "metric." + SOME_VARIATION_METRIC.getKey() + ".name", SOME_VARIATION_METRIC.getName())) .thenReturn(metricMsg); - Condition condition = new Condition(SOME_VARIATION_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, null); + Condition condition = new Condition(SOME_VARIATION_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, false); assertThat(underTest.asText(condition, new EvaluationResult(level, null))) .isEqualTo(metricMsg + " " + toSign(operator) + " " + getThreshold(level)); @@ -134,10 +134,10 @@ public class EvaluationResultTextConverterTest { Date date = new Date(); Period period = new Period(periodIndex, SOME_MODE, null, date.getTime(), SOME_ANALYSIS_UUID); - periodsHolder.setPeriods(period); + periodsHolder.setPeriod(period); when(periods.label(period.getMode(), period.getModeParameter(), date)).thenReturn(periodLabel); - Condition condition = new Condition(SOME_VARIATION_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, periodIndex); + Condition condition = new Condition(SOME_VARIATION_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, true); assertThat(underTest.asText(condition, new EvaluationResult(level, null))) .isEqualTo(metricMsg + " " + toSign(operator) + " " + (getThreshold(level)) + " " + periodLabel); @@ -157,10 +157,10 @@ public class EvaluationResultTextConverterTest { Date date = new Date(); Period period = new Period(periodIndex, SOME_MODE, null, date.getTime(), SOME_ANALYSIS_UUID); - periodsHolder.setPeriods(period); + periodsHolder.setPeriod(period); when(periods.label(period.getMode(), period.getModeParameter(), date)).thenReturn(periodLabel); - Condition condition = new Condition(INT_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, periodIndex); + Condition condition = new Condition(INT_METRIC, operator.getDbValue(), ERROR_THRESHOLD, WARNING_THRESHOLD, true); assertThat(underTest.asText(condition, new EvaluationResult(level, null))) .isEqualTo(metricMsg + " " + variationMsg + " " + toSign(operator) + " " + (getThreshold(level)) + " " + periodLabel); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java index 3f3a1ca8184..97038bd74a5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java @@ -43,7 +43,8 @@ public class QualityGateServiceImplTest { private static final long METRIC_ID_2 = 753; private static final Metric METRIC_1 = mock(Metric.class); private static final Metric METRIC_2 = mock(Metric.class); - private static final QualityGateConditionDto CONDITION_1 = new QualityGateConditionDto().setId(321).setMetricId(METRIC_ID_1).setOperator("EQ").setPeriod(1).setWarningThreshold("warnin_th").setErrorThreshold("error_th"); + private static final QualityGateConditionDto CONDITION_1 = new QualityGateConditionDto().setId(321).setMetricId(METRIC_ID_1).setOperator("EQ").setPeriod(1) + .setWarningThreshold("warnin_th").setErrorThreshold("error_th"); private static final QualityGateConditionDto CONDITION_2 = new QualityGateConditionDto().setId(456).setMetricId(METRIC_ID_2).setOperator("NE"); private QualityGateDao qualityGateDao = mock(QualityGateDao.class); @@ -83,8 +84,7 @@ public class QualityGateServiceImplTest { assertThat(res.get().getId()).isEqualTo(SOME_ID); assertThat(res.get().getName()).isEqualTo(SOME_NAME); assertThat(res.get().getConditions()).containsOnly( - new Condition(METRIC_1, CONDITION_1.getOperator(), CONDITION_1.getErrorThreshold(), CONDITION_1.getWarningThreshold(), CONDITION_1.getPeriod()), - new Condition(METRIC_2, CONDITION_2.getOperator(), CONDITION_2.getErrorThreshold(), CONDITION_2.getWarningThreshold(), CONDITION_2.getPeriod()) - ); + new Condition(METRIC_1, CONDITION_1.getOperator(), CONDITION_1.getErrorThreshold(), CONDITION_1.getWarningThreshold(), true), + new Condition(METRIC_2, CONDITION_2.getOperator(), CONDITION_2.getErrorThreshold(), CONDITION_2.getWarningThreshold(), false)); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java index 08174fed707..ae6c86c7622 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java @@ -25,9 +25,9 @@ import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonar.api.notifications.Notification; -import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.ReportComponent; +import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.event.Event; import org.sonar.server.computation.task.projectanalysis.event.EventRepository; import org.sonar.server.computation.task.projectanalysis.measure.Measure; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStepTest.java index 5900f768b8b..5fa21809540 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStepTest.java @@ -32,9 +32,9 @@ import org.junit.rules.ExpectedException; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.sonar.api.measures.CoreMetrics; -import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.ReportComponent; +import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.measure.Measure; import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule; import org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition; @@ -58,10 +58,10 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY; +import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder; import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.ERROR; import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.OK; import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.WARN; -import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder; import static org.sonar.server.computation.task.projectanalysis.measure.MeasureAssert.assertThat; import static org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations.newMeasureVariationsBuilder; @@ -279,7 +279,7 @@ public class QualityGateMeasuresStepTest { public void new_measure_has_ERROR_level_of_all_conditions_for_a_specific_metric_if_its_the_worst() { int rawValue = 1; Condition fixedCondition = createEqualsCondition(INT_METRIC_1, "1", null); - Condition periodCondition = createEqualsCondition(INT_METRIC_1, null, "2", 1); + Condition periodCondition = createEqualsCondition(INT_METRIC_1, null, "2", true); qualityGateHolder.setQualityGate(new QualityGate(SOME_QG_ID, SOME_QG_NAME, of(fixedCondition, periodCondition))); Measure measure = newMeasureBuilder().create(rawValue, null); @@ -297,7 +297,7 @@ public class QualityGateMeasuresStepTest { public void new_measure_has_WARN_level_of_all_conditions_for_a_specific_metric_if_its_the_worst() { int rawValue = 2; Condition fixedCondition = createEqualsCondition(INT_METRIC_1, "1", null); - Condition periodCondition = createEqualsCondition(INT_METRIC_1, null, "2", 1); + Condition periodCondition = createEqualsCondition(INT_METRIC_1, null, "2", true); qualityGateHolder.setQualityGate(new QualityGate(SOME_QG_ID, SOME_QG_NAME, of(fixedCondition, periodCondition))); Measure measure = newMeasureBuilder() @@ -317,20 +317,20 @@ public class QualityGateMeasuresStepTest { public void new_measure_has_condition_on_leak_period_when_all_conditions_on_specific_metric_has_same_QG_level() { int rawValue = 1; Condition fixedCondition = createEqualsCondition(INT_METRIC_1, "1", null); - Condition periodCondition = createEqualsCondition(INT_METRIC_1, "1", null, 1); + Condition periodCondition = createEqualsCondition(INT_METRIC_1, "1", null, true); qualityGateHolder.setQualityGate(new QualityGate(SOME_QG_ID, SOME_QG_NAME, of(fixedCondition, periodCondition))); Measure measure = newMeasureBuilder() - .setVariations(newMeasureVariationsBuilder().setVariation(new Period(1, "mode", null, 1212, "u1"), rawValue).build()) - .create(rawValue, null); + .setVariation(rawValue) + .create(rawValue, null); measureRepository.addRawMeasure(PROJECT_REF, INT_METRIC_1_KEY, measure); underTest.execute(); Optional rawMeasure1 = measureRepository.getAddedRawMeasure(PROJECT_REF, INT_METRIC_1_KEY); assertThat(rawMeasure1.get()) - .hasQualityGateLevel(ERROR) - .hasQualityGateText(dumbResultTextAnswer(periodCondition, ERROR, rawValue)); + .hasQualityGateLevel(ERROR) + .hasQualityGateText(dumbResultTextAnswer(periodCondition, ERROR, rawValue)); } private Measure getAlertStatusMeasure() { @@ -342,11 +342,11 @@ public class QualityGateMeasuresStepTest { } private static Condition createEqualsCondition(Metric metric, @Nullable String errorThreshold, @Nullable String warningThreshold) { - return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), errorThreshold, warningThreshold, null); + return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), errorThreshold, warningThreshold, false); } - private static Condition createEqualsCondition(Metric metric, @Nullable String errorThreshold, @Nullable String warningThreshold, @Nullable Integer period) { - return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), errorThreshold, warningThreshold, period); + private static Condition createEqualsCondition(Metric metric, @Nullable String errorThreshold, @Nullable String warningThreshold, boolean hasPeriod) { + return new Condition(metric, Condition.Operator.EQUALS.getDbValue(), errorThreshold, warningThreshold, hasPeriod); } private static MetricImpl createIntMetric(int index) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportComputeMeasureVariationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportComputeMeasureVariationsStepTest.java index 4a4d303f024..ee7bab1d886 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportComputeMeasureVariationsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportComputeMeasureVariationsStepTest.java @@ -31,10 +31,10 @@ import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.SnapshotDto; import org.sonar.db.measure.MeasureDto; import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule; -import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.component.Component; import org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper; import org.sonar.server.computation.task.projectanalysis.component.ReportComponent; +import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.server.computation.task.projectanalysis.measure.Measure; import org.sonar.server.computation.task.projectanalysis.measure.MeasureRepositoryRule; import org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations;