use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class AppActionTest method insertFileMeasure.
private void insertFileMeasure(int metricId, @Nullable Double value, @Nullable String data) {
MeasureDto measure = MeasureTesting.newMeasure().setComponentUuid(FILE_UUID).setAnalysisUuid(ANALYSIS_UUID).setMetricId(metricId).setValue(value).setData(data);
dbTester.getDbClient().measureDao().insert(dbTester.getSession(), measure);
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureToMeasureDtoTest method toMeasureDto_maps_value_and_data_from_data_field_for_LONG_metric.
@Test
public void toMeasureDto_maps_value_and_data_from_data_field_for_LONG_metric() {
MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create((long) 456, SOME_DATA), SOME_LONG_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isEqualTo(456);
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_DATA);
}
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);
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_ignores_data.
@Test(expected = IllegalStateException.class)
public void toMeasure_for_LEVEL_Metric_ignores_data() {
MeasureDto measureDto = new MeasureDto().setAlertStatus(Level.ERROR.name()).setData(SOME_DATA);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_LEVEL_METRIC);
assertThat(measure).isPresent();
measure.get().getStringValue();
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureDtoToMeasureTest method toMeasure_maps_alert_properties_in_dto_for_String_Metric.
@Test
public void toMeasure_maps_alert_properties_in_dto_for_String_Metric() {
MeasureDto measureDto = new MeasureDto().setData(SOME_DATA).setAlertStatus(Level.OK.name()).setAlertText(SOME_ALERT_TEXT);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_STRING_METRIC);
assertThat(measure.isPresent()).isTrue();
assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.STRING);
assertThat(measure.get().getStringValue()).isEqualTo(SOME_DATA);
assertThat(measure.get().getData()).isEqualTo(SOME_DATA);
assertThat(measure.get().getQualityGateStatus().getStatus()).isEqualTo(Level.OK);
assertThat(measure.get().getQualityGateStatus().getText()).isEqualTo(SOME_ALERT_TEXT);
}
Aggregations