Search in sources :

Example 21 with Measure

use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.

the class ConditionEvaluatorTest method testEquals_work_duration.

@Test
public void testEquals_work_duration() {
    Metric metric = createMetric(WORK_DUR);
    Measure measure = newMeasureBuilder().create(60l, null);
    assertThat(underTest.evaluate(createErrorCondition(metric, EQUALS, "60"), measure)).hasLevel(ERROR);
}
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 22 with Measure

use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.

the class ConditionEvaluatorTest method testNotEquals_for_double.

@Test
public void testNotEquals_for_double() {
    Metric metric = createMetric(FLOAT);
    Measure measure = newMeasureBuilder().create(10.2d, 1, null);
    assertThat(underTest.evaluate(createErrorCondition(metric, NOT_EQUALS, "10.2"), measure)).hasLevel(OK).hasValue(10.2d);
    assertThat(underTest.evaluate(createErrorCondition(metric, NOT_EQUALS, "10.1"), 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)

Example 23 with Measure

use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.

the class ConditionEvaluatorTest method getLevel_throws_IEA_if_error_threshold_is_not_parsable_boolean.

@Test
public void getLevel_throws_IEA_if_error_threshold_is_not_parsable_boolean() {
    Metric metric = createMetric(BOOL);
    Measure measure = newMeasureBuilder().create(false, null);
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Quality Gate: Unable to parse value 'polop' to compare against name");
    underTest.evaluate(createErrorCondition(metric, EQUALS, "polop"), measure);
}
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 24 with Measure

use of org.sonar.server.computation.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);
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Quality Gate: Unable to parse value 'polop' to compare against name");
    underTest.evaluate(createErrorCondition(metric, EQUALS, "polop"), measure);
}
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 25 with Measure

use of org.sonar.server.computation.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(createErrorCondition(metric, GREATER_THAN, "10.1"), measure)).hasLevel(ERROR).hasValue(10.2d);
    assertThat(underTest.evaluate(createErrorCondition(metric, GREATER_THAN, "10.2"), measure)).hasLevel(OK).hasValue(10.2d);
    assertThat(underTest.evaluate(createErrorCondition(metric, GREATER_THAN, "10.3"), 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)

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