use of org.sonarqube.ws.client.measure.ComponentTreeWsRequest 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.sonarqube.ws.client.measure.ComponentTreeWsRequest in project sonarqube by SonarSource.
the class ComponentTreeSortTest method sort_by_numerical_metric_period_1_key_descending.
@Test
public void sort_by_numerical_metric_period_1_key_descending() {
components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure"));
ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_PERIOD_SORT), false, NUM_METRIC_KEY).setMetricPeriodSort(1);
List<ComponentDto> result = sortComponents(wsRequest);
assertThat(result).extracting("path").containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9", "path-without-measure");
}
use of org.sonarqube.ws.client.measure.ComponentTreeWsRequest in project sonarqube by SonarSource.
the class ComponentTreeSortTest method sort_by_path.
@Test
public void sort_by_path() {
ComponentTreeWsRequest wsRequest = newRequest(singletonList(PATH_SORT), true, null);
List<ComponentDto> result = sortComponents(wsRequest);
assertThat(result).extracting("path").containsExactly("path-1", "path-2", "path-3", "path-4", "path-5", "path-6", "path-7", "path-8", "path-9");
}
use of org.sonarqube.ws.client.measure.ComponentTreeWsRequest in project sonarqube by SonarSource.
the class ComponentTreeSortTest method sort_by_numerical_metric_period_5_key.
@Test
public void sort_by_numerical_metric_period_5_key() {
components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure"));
ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), false, NUM_METRIC_KEY).setMetricPeriodSort(5);
List<ComponentDto> result = sortComponents(wsRequest);
assertThat(result).extracting("path").containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure");
}
use of org.sonarqube.ws.client.measure.ComponentTreeWsRequest in project sonarqube by SonarSource.
the class ComponentTreeSortTest method sort_by_numerical_metric_key_descending.
@Test
public void sort_by_numerical_metric_key_descending() {
components.add(newComponentWithoutSnapshotId("name-without-measure", "qualifier-without-measure", "path-without-measure"));
ComponentTreeWsRequest wsRequest = newRequest(singletonList(METRIC_SORT), false, NUM_METRIC_KEY);
List<ComponentDto> result = sortComponents(wsRequest);
assertThat(result).extracting("path").containsExactly("path-9", "path-8", "path-7", "path-6", "path-5", "path-4", "path-3", "path-2", "path-1", "path-without-measure");
}
Aggregations