use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureToMeasureDtoTest method toMeasureDto_maps_to_only_data_for_STRING_metric.
@Test
public void toMeasureDto_maps_to_only_data_for_STRING_metric() {
MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isNull();
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_STRING);
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureToMeasureDtoTest method toMeasureDto_returns_Dto_without_any_variation_if_Measure_has_no_MeasureVariations.
@Test
@UseDataProvider("all_types_Measures")
public void toMeasureDto_returns_Dto_without_any_variation_if_Measure_has_no_MeasureVariations(Measure measure, Metric metric) {
MeasureDto measureDto = underTest.toMeasureDto(measure, metric, SOME_COMPONENT);
assertThat(measureDto.getVariation()).isNull();
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureDtoToMeasureTest method toMeasure_maps_data_and_alert_properties_in_dto_for_Long_Metric.
@Test
public void toMeasure_maps_data_and_alert_properties_in_dto_for_Long_Metric() {
MeasureDto measureDto = new MeasureDto().setValue(10d).setData(SOME_DATA).setAlertStatus(Level.OK.name()).setAlertText(SOME_ALERT_TEXT);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_LONG_METRIC);
assertThat(measure).isPresent();
assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.LONG);
assertThat(measure.get().getLongValue()).isEqualTo(10);
assertThat(measure.get().getData()).isEqualTo(SOME_DATA);
assertThat(measure.get().getQualityGateStatus().getStatus()).isEqualTo(Level.OK);
assertThat(measure.get().getQualityGateStatus().getText()).isEqualTo(SOME_ALERT_TEXT);
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureDtoToMeasureTest method toMeasure_should_not_loose_decimals_of_float_values.
@Test
public void toMeasure_should_not_loose_decimals_of_float_values() {
MetricImpl metric = new MetricImpl("42", "double", "name", Metric.MetricType.FLOAT, 5, null, false, false);
MeasureDto measureDto = new MeasureDto().setValue(0.12345);
Optional<Measure> measure = underTest.toMeasure(measureDto, metric);
assertThat(measure.get().getDoubleValue()).isEqualTo(0.12345, Offset.offset(0.000001));
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureDtoToMeasureTest method toMeasure_for_LEVEL_Metric_can_have_an_qualityGateStatus.
@Test
public void toMeasure_for_LEVEL_Metric_can_have_an_qualityGateStatus() {
MeasureDto measureDto = new MeasureDto().setData(Level.OK.name()).setAlertStatus(Level.ERROR.name()).setAlertText(SOME_ALERT_TEXT);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_LEVEL_METRIC);
assertThat(measure).isPresent();
assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.LEVEL);
assertThat(measure.get().getLevelValue()).isEqualTo(Level.OK);
assertThat(measure.get().getQualityGateStatus().getStatus()).isEqualTo(Level.ERROR);
assertThat(measure.get().getQualityGateStatus().getText()).isEqualTo(SOME_ALERT_TEXT);
}
Aggregations