use of org.sonar.ce.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class MeasureRepositoryImplTest method metricOf.
private Metric metricOf(MetricDto metricDto) {
Metric res = mock(Metric.class);
when(res.getKey()).thenReturn(metricDto.getKey());
when(res.getUuid()).thenReturn(metricDto.getUuid());
when(res.getType()).thenReturn(Metric.MetricType.valueOf(metricDto.getValueType()));
return res;
}
use of org.sonar.ce.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class MapBasedRawMeasureRepositoryTest method update_accepts_NO_VALUE_as_measure_arg.
@Test
public void update_accepts_NO_VALUE_as_measure_arg() {
for (Metric.MetricType metricType : Metric.MetricType.values()) {
MetricImpl metric = new MetricImpl("1", "key" + metricType, "name" + metricType, metricType);
underTest.add(FILE_COMPONENT, metric, getSomeMeasureByValueType(metricType));
underTest.update(FILE_COMPONENT, metric, Measure.newMeasureBuilder().createNoValue());
}
}
use of org.sonar.ce.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method condition_is_always_ok_when_measure_is_noValue.
@Test
public void condition_is_always_ok_when_measure_is_noValue() {
for (MetricType metricType : from(asList(values())).filter(not(in(ImmutableSet.of(BOOL, DATA, DISTRIB, STRING))))) {
Metric metric = createMetric(metricType);
Measure measure = newMeasureBuilder().createNoValue();
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.2"), measure)).hasLevel(OK);
}
}
use of org.sonar.ce.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method fail_when_condition_on_leak_period_is_using_unsupported_metric.
@Test
public void fail_when_condition_on_leak_period_is_using_unsupported_metric() {
Metric metric = createNewMetric(LEVEL);
Measure measure = newMeasureBuilder().setVariation(0d).createNoValue();
assertThatThrownBy(() -> underTest.evaluate(new Condition(metric, LESS_THAN.getDbValue(), "3"), measure)).isInstanceOf(IllegalArgumentException.class).hasMessage("Unsupported metric type LEVEL");
}
use of org.sonar.ce.task.projectanalysis.metric.Metric in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testErrorLevel.
@Test
public void testErrorLevel() {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.3"), measure)).hasLevel(ERROR);
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.1"), measure)).hasLevel(OK);
assertThat(underTest.evaluate(new Condition(metric, LESS_THAN.getDbValue(), "10.3"), measure)).hasLevel(Measure.Level.ERROR);
}
Aggregations