use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method assertVariation.
private void assertVariation(Component component, String metricKey, int variation) {
Measure newMeasure = measureRepository.getRawMeasure(component, metricRepository.getByKey(metricKey)).get();
assertThat(newMeasure.getVariation()).isEqualTo(variation);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testErrorAndWarningLevel.
@Test
public void testErrorAndWarningLevel() {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
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", 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);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testNotEquals.
@Test
public void testNotEquals() {
Metric metric = createMetric(STRING);
Measure measure = newMeasureBuilder().create("TEST");
assertThat(underTest.evaluate(createErrorCondition(metric, NOT_EQUALS, "TEST"), measure)).hasLevel(OK).hasValue("TEST");
assertThat(underTest.evaluate(createErrorCondition(metric, NOT_EQUALS, "TEST2"), measure)).hasLevel(ERROR).hasValue("TEST");
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testEquals_for_String.
@Test
public void testEquals_for_String() {
Metric metric = createMetric(STRING);
Measure measure = newMeasureBuilder().create("TEST");
assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "TEST"), measure)).hasLevel(ERROR).hasValue("TEST");
assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "TEST2"), measure)).hasLevel(OK).hasValue("TEST");
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method test_condition_on_rating_on_leak_period.
@Test
public void test_condition_on_rating_on_leak_period() throws Exception {
Metric metric = createMetric(RATING);
Measure measure = newMeasureBuilder().setVariation(4d).createNoValue();
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);
}
Aggregations