Search in sources :

Example 1 with Developer

use of org.sonar.server.computation.task.projectanalysis.component.Developer in project sonarqube by SonarSource.

the class MeasureToMeasureDto method toMeasureDto.

@Nonnull
public MeasureDto toMeasureDto(Measure measure, Metric metric, Component component) {
    MeasureDto out = new MeasureDto();
    out.setMetricId(metric.getId());
    out.setComponentUuid(component.getUuid());
    out.setAnalysisUuid(analysisMetadataHolder.getUuid());
    if (measure.hasVariation()) {
        out.setVariation(measure.getVariation());
    }
    if (measure.hasQualityGateStatus()) {
        setAlert(out, measure.getQualityGateStatus());
    }
    Developer developer = measure.getDeveloper();
    if (developer != null) {
        out.setDeveloperId(dbIdsRepository.getDeveloperId(developer));
    }
    out.setDescription(measure.getDescription());
    out.setValue(valueAsDouble(measure));
    out.setData(data(measure));
    return out;
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) Developer(org.sonar.server.computation.task.projectanalysis.component.Developer) Nonnull(javax.annotation.Nonnull)

Example 2 with Developer

use of org.sonar.server.computation.task.projectanalysis.component.Developer in project sonarqube by SonarSource.

the class MeasureToMeasureDtoTest method toMeasureDto_sets_developerId_if_set_in_Measure.

@Test
public void toMeasureDto_sets_developerId_if_set_in_Measure() {
    Developer developer = new DumbDeveloper("DEV1");
    dbIdsRepository.setDeveloperId(developer, 42);
    Measure measure = Measure.newMeasureBuilder().forDeveloper(developer).createNoValue();
    assertThat(underTest.toMeasureDto(measure, SOME_BOOLEAN_METRIC, SOME_COMPONENT).getDeveloperId()).isEqualTo(42);
}
Also used : DumbDeveloper(org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper) Developer(org.sonar.server.computation.task.projectanalysis.component.Developer) DumbDeveloper(org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper) Test(org.junit.Test)

Example 3 with Developer

use of org.sonar.server.computation.task.projectanalysis.component.Developer in project sonarqube by SonarSource.

the class PersistMeasuresStepTest method insert_developer_measure_from_report.

@Test
public void insert_developer_measure_from_report() {
    setupReportComponents();
    metricRepository.add(1, INT_METRIC);
    Developer developer = new DumbDeveloper("DEV1");
    dbIdsRepository.setDeveloperId(developer, 10);
    measureRepository.addRawMeasure(ROOT_REF, INT_METRIC_KEY, newMeasureBuilder().forDeveloper(developer).create(1));
    underTest.execute();
    assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(1);
    List<Map<String, Object>> dtos = selectSnapshots();
    Map<String, Object> dto = dtos.get(0);
    assertValue(dto, 1d);
    assertThat(dto.get("developerId")).isEqualTo(10L);
}
Also used : Developer(org.sonar.server.computation.task.projectanalysis.component.Developer) DumbDeveloper(org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper) DumbDeveloper(org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Developer (org.sonar.server.computation.task.projectanalysis.component.Developer)3 Test (org.junit.Test)2 DumbDeveloper (org.sonar.server.computation.task.projectanalysis.component.DumbDeveloper)2 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 MeasureDto (org.sonar.db.measure.MeasureDto)1