Search in sources :

Example 26 with MeasureDto

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);
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto)

Example 27 with MeasureDto

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);
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test)

Example 28 with MeasureDto

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));
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) MetricImpl(org.sonar.server.computation.task.projectanalysis.metric.MetricImpl) Test(org.junit.Test)

Example 29 with MeasureDto

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();
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Test(org.junit.Test)

Example 30 with MeasureDto

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);
}
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