use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class MeasureToMeasureDtoTest method toMeasureDto_maps_to_only_data_for_STRING_metric.
@Test
public void toMeasureDto_maps_to_only_data_for_STRING_metric() {
MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isNull();
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_STRING);
}
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_INT_metric.
@Test
public void toMeasureDto_maps_value_and_data_from_data_field_for_INT_metric() {
MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create(123, SOME_DATA), SOME_INT_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isEqualTo(123);
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_DATA);
}
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_DOUBLE_metric.
@Test
public void toMeasureDto_maps_value_and_data_from_data_field_for_DOUBLE_metric() {
MeasureDto trueMeasureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().create((double) 789, 1, SOME_DATA), SOME_DOUBLE_METRIC, SOME_COMPONENT);
assertThat(trueMeasureDto.getValue()).isEqualTo(789);
assertThat(trueMeasureDto.getData()).isEqualTo(SOME_DATA);
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ComponentTreeSortTest method sort_by_alert_status_ascending.
@Test
public void sort_by_alert_status_ascending() {
components = newArrayList(newComponentWithoutSnapshotId("PROJECT OK 1", Qualifiers.PROJECT, "PROJECT_OK_PATH_1"), newComponentWithoutSnapshotId("PROJECT WARN 1", Qualifiers.PROJECT, "PROJECT_WARN_PATH_1"), newComponentWithoutSnapshotId("PROJECT ERROR 1", Qualifiers.PROJECT, "PROJECT_ERROR_PATH_1"), newComponentWithoutSnapshotId("PROJECT OK 2", Qualifiers.PROJECT, "PROJECT_OK_PATH_2"), newComponentWithoutSnapshotId("PROJECT WARN 2", Qualifiers.PROJECT, "PROJECT_WARN_PATH_2"), newComponentWithoutSnapshotId("PROJECT ERROR 2", Qualifiers.PROJECT, "PROJECT_ERROR_PATH_2"));
metrics = singletonList(newMetricDto().setKey(CoreMetrics.ALERT_STATUS_KEY).setValueType(ValueType.LEVEL.name()));
measuresByComponentUuidAndMetric = HashBasedTable.create();
List<String> statuses = newArrayList("OK", "WARN", "ERROR");
for (int i = 0; i < components.size(); i++) {
ComponentDto component = components.get(i);
String alertStatus = statuses.get(i % 3);
measuresByComponentUuidAndMetric.put(component.uuid(), metrics.get(0), new MeasureDto().setData(alertStatus));
}
ComponentTreeWsRequest wsRequest = newRequest(newArrayList(METRIC_SORT, NAME_SORT), true, CoreMetrics.ALERT_STATUS_KEY);
List<ComponentDto> result = sortComponents(wsRequest);
assertThat(result).extracting("name").containsExactly("PROJECT ERROR 1", "PROJECT ERROR 2", "PROJECT WARN 1", "PROJECT WARN 2", "PROJECT OK 1", "PROJECT OK 2");
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class AppAction method handle.
@Override
public void handle(Request request, Response response) {
try (DbSession session = dbClient.openSession(false)) {
ComponentDto component = componentFinder.getByUuidOrKey(session, request.param(PARAM_COMPONENT_ID), request.param(PARAM_COMPONENT), ParamNames.COMPONENT_ID_AND_COMPONENT);
userSession.checkComponentPermission(UserRole.USER, component);
JsonWriter json = response.newJsonWriter();
json.beginObject();
Map<String, MeasureDto> measuresByMetricKey = measuresByMetricKey(component, session);
appendComponent(json, component, userSession, session);
appendPermissions(json, component, userSession);
appendMeasures(json, measuresByMetricKey);
json.endObject();
json.close();
}
}
Aggregations