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);
}
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_Int_Metric.
@Test
public void toMeasure_maps_data_and_alert_properties_in_dto_for_Int_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_INT_METRIC);
assertThat(measure.isPresent()).isTrue();
assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.INT);
assertThat(measure.get().getIntValue()).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_maps_data_and_alert_properties_in_dto_for_Boolean_metric.
@Test
public void toMeasure_maps_data_and_alert_properties_in_dto_for_Boolean_metric() {
MeasureDto measureDto = new MeasureDto().setValue(1d).setData(SOME_DATA).setAlertStatus(Level.OK.name()).setAlertText(SOME_ALERT_TEXT);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_BOOLEAN_METRIC);
assertThat(measure.isPresent()).isTrue();
assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.BOOLEAN);
assertThat(measure.get().getBooleanValue()).isTrue();
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_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