Search in sources :

Example 11 with MeasureDto

use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_maps_name_of_Level_to_data_and_has_no_value_for_LEVEL_metric.

@Test
public void toMeasureDto_maps_name_of_Level_to_data_and_has_no_value_for_LEVEL_metric() {
    MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create(Measure.Level.OK), SOME_LEVEL_METRIC, SOME_COMPONENT);
    assertThat(trueMeasureDto.getValue()).isNull();
    assertThat(trueMeasureDto.getData()).isEqualTo(Measure.Level.OK.name());
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test)

Example 12 with MeasureDto

use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_returns_Dto_with_variation_if_Measure_has_MeasureVariations.

@Test
public void toMeasureDto_returns_Dto_with_variation_if_Measure_has_MeasureVariations() {
    MeasureDto measureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().setVariation(SOME_VARIATIONS).create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
    assertThat(measureDto.getVariation()).isEqualTo(1d);
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test)

Example 13 with MeasureDto

use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_set_componentId_and_snapshotId_from_method_arguments.

@Test
@UseDataProvider("all_types_Measures")
public void toMeasureDto_set_componentId_and_snapshotId_from_method_arguments(Measure measure, Metric metric) {
    MeasureDto measureDto = underTest.toMeasureDto(measure, metric, SOME_COMPONENT);
    assertThat(measureDto.getComponentUuid()).isEqualTo(SOME_COMPONENT.getUuid());
// assertThat(measureDto.getSnapshotId()).isEqualTo(SOME_SNAPSHOT_ID);
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 14 with MeasureDto

use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_returns_Dto_without_alertStatus_nor_alertText_if_Measure_has_no_QualityGateStatus.

@Test
@UseDataProvider("all_types_Measures")
public void toMeasureDto_returns_Dto_without_alertStatus_nor_alertText_if_Measure_has_no_QualityGateStatus(Measure measure, Metric metric) {
    MeasureDto measureDto = underTest.toMeasureDto(measure, metric, SOME_COMPONENT);
    assertThat(measureDto.getAlertStatus()).isNull();
    assertThat(measureDto.getAlertText()).isNull();
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 15 with MeasureDto

use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_returns_Dto_with_alertStatus_and_alertText_if_Measure_has_QualityGateStatus.

@Test
public void toMeasureDto_returns_Dto_with_alertStatus_and_alertText_if_Measure_has_QualityGateStatus() {
    String alertText = "some error";
    MeasureDto measureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().setQualityGateStatus(new QualityGateStatus(Measure.Level.ERROR, alertText)).create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
    assertThat(measureDto.getAlertStatus()).isEqualTo(Measure.Level.ERROR.name());
    assertThat(measureDto.getAlertText()).isEqualTo(alertText);
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test)

Aggregations

MeasureDto (org.sonar.db.measure.MeasureDto)36 Test (org.junit.Test)21 MetricDto (org.sonar.db.metric.MetricDto)9 ComponentDto (org.sonar.db.component.ComponentDto)7 MeasureQuery (org.sonar.db.measure.MeasureQuery)6 DbSession (org.sonar.db.DbSession)4 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3 SnapshotDto (org.sonar.db.component.SnapshotDto)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CheckForNull (javax.annotation.CheckForNull)1 Nonnull (javax.annotation.Nonnull)1 Before (org.junit.Before)1 JsonWriter (org.sonar.api.utils.text.JsonWriter)1 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)1 ComponentTreeQuery (org.sonar.db.component.ComponentTreeQuery)1 MeasureTreeQuery (org.sonar.db.measure.MeasureTreeQuery)1 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)1 Developer (org.sonar.server.computation.task.projectanalysis.component.Developer)1