use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ComponentDtoToWsComponent method componentDtoToWsComponent.
static Component.Builder componentDtoToWsComponent(ComponentDto component, Map<MetricDto, MeasureDto> measuresByMetric, Map<String, ComponentDto> referenceComponentsByUuid) {
Component.Builder wsComponent = componentDtoToWsComponent(component);
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
if (referenceComponent != null) {
wsComponent.setRefId(referenceComponent.uuid());
wsComponent.setRefKey(referenceComponent.key());
}
for (Map.Entry<MetricDto, MeasureDto> entry : measuresByMetric.entrySet()) {
wsComponent.addMeasures(measureDtoToWsMeasure(entry.getKey(), entry.getValue()));
}
return wsComponent;
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class SearchMyProjectsDataLoader method load.
SearchMyProjectsData load(DbSession dbSession, SearchMyProjectsRequest request) {
SearchMyProjectsData.Builder data = builder();
ProjectsResult searchResult = searchProjects(dbSession, request);
List<ComponentDto> projects = searchResult.projects;
List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
List<ComponentLinkDto> projectLinks = dbClient.componentLinkDao().selectByComponentUuids(dbSession, projectUuids);
List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession, projectUuids);
MetricDto gateStatusMetric = dbClient.metricDao().selectOrFailByKey(dbSession, CoreMetrics.ALERT_STATUS_KEY);
MeasureQuery measureQuery = MeasureQuery.builder().setProjectUuids(projectUuids).setMetricId(gateStatusMetric.getId()).build();
List<MeasureDto> qualityGates = dbClient.measureDao().selectByQuery(dbSession, measureQuery);
data.setProjects(projects).setProjectLinks(projectLinks).setSnapshots(snapshots).setQualityGates(qualityGates).setTotalNbOfProjects(searchResult.total);
return data.build();
}
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()).isTrue();
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_creates_MeasureVariation_and_maps_the_right_one.
@Test
public void toMeasure_creates_MeasureVariation_and_maps_the_right_one() {
MeasureDto measureDto = new MeasureDto().setData("1").setVariation(2d);
Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_STRING_METRIC);
assertThat(measure.get().getVariation()).isEqualTo(2);
}
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();
}
Aggregations