Search in sources :

Example 6 with ComponentTreeWsRequest

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");
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) ComponentDto(org.sonar.db.component.ComponentDto) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) Test(org.junit.Test)

Example 7 with ComponentTreeWsRequest

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");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) Test(org.junit.Test)

Example 8 with ComponentTreeWsRequest

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");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) Test(org.junit.Test)

Example 9 with ComponentTreeWsRequest

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");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) Test(org.junit.Test)

Example 10 with ComponentTreeWsRequest

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");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) Test(org.junit.Test)

Aggregations

ComponentTreeWsRequest (org.sonarqube.ws.client.measure.ComponentTreeWsRequest)16 Test (org.junit.Test)14 ComponentDto (org.sonar.db.component.ComponentDto)12 ComponentTreeWsResponse (org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse)2 CollectionCondition (com.codeborne.selenide.CollectionCondition)1 Condition (com.codeborne.selenide.Condition)1 Condition.hasText (com.codeborne.selenide.Condition.hasText)1 Condition.or (com.codeborne.selenide.Condition.or)1 Orchestrator (com.sonar.orchestrator.Orchestrator)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 BeforeClass (org.junit.BeforeClass)1 ClassRule (org.junit.ClassRule)1 MeasureDto (org.sonar.db.measure.MeasureDto)1 Issues (org.sonarqube.ws.Issues)1 WsComponents (org.sonarqube.ws.WsComponents)1 WsMeasures (org.sonarqube.ws.WsMeasures)1 WsClient (org.sonarqube.ws.client.WsClient)1 TreeWsRequest (org.sonarqube.ws.client.component.TreeWsRequest)1