Search in sources :

Example 6 with Measure

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));
}
Also used : Measure(org.sonar.server.computation.task.projectanalysis.measure.Measure)

Example 7 with Measure

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();
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Measure(org.sonar.server.computation.task.projectanalysis.measure.Measure) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 8 with Measure

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);
}
Also used : Measure(org.sonar.server.computation.task.projectanalysis.measure.Measure) Metric(org.sonar.server.computation.task.projectanalysis.metric.Metric) Test(org.junit.Test)

Example 9 with Measure

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);
    }
}
Also used : MetricType(org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType) Measure(org.sonar.server.computation.task.projectanalysis.measure.Measure) Metric(org.sonar.server.computation.task.projectanalysis.metric.Metric) Test(org.junit.Test)

Example 10 with Measure

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);
}
Also used : Measure(org.sonar.server.computation.task.projectanalysis.measure.Measure) Metric(org.sonar.server.computation.task.projectanalysis.metric.Metric) Test(org.junit.Test)

Aggregations

Measure (org.sonar.server.computation.task.projectanalysis.measure.Measure)46 Test (org.junit.Test)35 Metric (org.sonar.server.computation.task.projectanalysis.metric.Metric)30 EvaluatedCondition (org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.EvaluatedCondition)8 Condition (org.sonar.server.computation.task.projectanalysis.qualitygate.Condition)8 QualityGate (org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGate)7 QualityGateDetailsData (org.sonar.server.computation.task.projectanalysis.measure.qualitygatedetails.QualityGateDetailsData)5 FileAttributes (org.sonar.server.computation.task.projectanalysis.component.FileAttributes)3 QualityGateStatus (org.sonar.server.computation.task.projectanalysis.measure.QualityGateStatus)3 MetricType (org.sonar.server.computation.task.projectanalysis.metric.Metric.MetricType)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Collection (java.util.Collection)1 Map (java.util.Map)1 CustomMeasureDto (org.sonar.db.measure.custom.CustomMeasureDto)1 ReportComponent (org.sonar.server.computation.task.projectanalysis.component.ReportComponent)1 VisitorsCrawler (org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler)1 ScmInfo (org.sonar.server.computation.task.projectanalysis.scm.ScmInfo)1