use of org.sonar.ce.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testGreater.
@Test
public void testGreater() {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
assertThat(underTest.evaluate(createCondition(metric, GREATER_THAN, "10.1"), measure)).hasLevel(ERROR).hasValue(10.2d);
assertThat(underTest.evaluate(createCondition(metric, GREATER_THAN, "10.2"), measure)).hasLevel(OK).hasValue(10.2d);
assertThat(underTest.evaluate(createCondition(metric, GREATER_THAN, "10.3"), measure)).hasLevel(OK).hasValue(10.2d);
}
use of org.sonar.ce.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testSmaller.
@Test
public void testSmaller() {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.1"), measure)).hasLevel(OK).hasValue(10.2d);
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.2"), measure)).hasLevel(OK).hasValue(10.2d);
assertThat(underTest.evaluate(createCondition(metric, LESS_THAN, "10.3"), measure)).hasLevel(ERROR).hasValue(10.2d);
}
use of org.sonar.ce.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method condition_on_new_metric_without_value_is_OK.
@Test
@UseDataProvider("numericNewMetricTypes")
public void condition_on_new_metric_without_value_is_OK(MetricType metricType) {
Metric metric = createNewMetric(metricType);
Measure measure = newMeasureBuilder().createNoValue();
assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3"), measure)).hasLevel(OK).hasValue(null);
}
use of org.sonar.ce.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method getLevel_throws_IEA_if_error_threshold_is_not_parsable_long.
@Test
public void getLevel_throws_IEA_if_error_threshold_is_not_parsable_long() {
Metric metric = createMetric(WORK_DUR);
Measure measure = newMeasureBuilder().create(60L, null);
assertThatThrownBy(() -> underTest.evaluate(createCondition(metric, LESS_THAN, "polop"), measure)).isInstanceOf(IllegalArgumentException.class).hasMessage("Quality Gate: Unable to parse value 'polop' to compare against name");
}
use of org.sonar.ce.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method test_input_numbers.
@Test
public void test_input_numbers() {
try {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
underTest.evaluate(createCondition(metric, LESS_THAN, "20"), measure);
} catch (NumberFormatException ex) {
fail();
}
try {
Metric metric = createMetric(INT);
Measure measure = newMeasureBuilder().create(5, null);
underTest.evaluate(createCondition(metric, LESS_THAN, "20.1"), measure);
} catch (NumberFormatException ex) {
fail();
}
try {
Metric metric = createMetric(PERCENT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
underTest.evaluate(createCondition(metric, LESS_THAN, "20.1"), measure);
} catch (NumberFormatException ex) {
fail();
}
}
Aggregations