use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class IssueCounterTest method assertVariation.
private void assertVariation(Component component, Metric metric, int expectedVariation) {
Measure measure = measureRepository.getRawMeasure(component, metric).get();
assertThat(measure.getVariation()).isEqualTo((double) expectedVariation, Offset.offset(0.01));
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class LastCommitVisitorTest method date_is_not_computed_on_file_if_blame_is_not_in_scm_repo.
@Test
public void date_is_not_computed_on_file_if_blame_is_not_in_scm_repo() throws Exception {
VisitorsCrawler underTest = new VisitorsCrawler(Lists.<ComponentVisitor>newArrayList(new LastCommitVisitor(metricRepository, measureRepository, scmInfoRepository)));
ReportComponent file = createFileComponent(FILE_1_REF);
treeRootHolder.setRoot(file);
underTest.visit(file);
Optional<Measure> measure = measureRepository.getAddedRawMeasure(FILE_1_REF, LAST_COMMIT_DATE_KEY);
assertThat(measure.isPresent()).isFalse();
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testEquals_for_double.
@Test
public void testEquals_for_double() {
Metric metric = createMetric(FLOAT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "10.2"), measure)).hasLevel(ERROR).hasValue(10.2d);
assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "10.1"), measure)).hasLevel(OK).hasValue(10.2d);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method test_condition_on_period.
@Test
public void test_condition_on_period() {
for (MetricType metricType : ImmutableList.of(FLOAT, INT, WORK_DUR)) {
Metric metric = createMetric(metricType);
Measure measure = newMeasureBuilder().setVariation(3d).createNoValue();
assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "3", null, true), measure)).hasLevel(OK);
}
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testEquals_Float.
@Test
public void testEquals_Float() {
Metric metric = createMetric(PERCENT);
Measure measure = newMeasureBuilder().create(10.2d, 1, null);
assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "10.2"), measure)).hasLevel(ERROR).hasValue(10.2d);
}
Aggregations