Search in sources :

Example 16 with ComponentTreeWsRequest

use of org.sonarqube.ws.client.measure.ComponentTreeWsRequest in project sonarqube by SonarSource.

the class LiteTest method call_measures_ws.

@Test
public void call_measures_ws() {
    // project measures
    WsMeasures.ComponentWsResponse component = wsClient.measures().component(new ComponentWsRequest().setComponentKey(PROJECT_KEY).setMetricKeys(asList("lines", "ncloc", "files")));
    assertThat(component.getComponent().getMeasuresCount()).isEqualTo(3);
    // file measures
    WsMeasures.ComponentTreeWsResponse tree = wsClient.measures().componentTree(new ComponentTreeWsRequest().setBaseComponentKey(PROJECT_KEY).setQualifiers(singletonList("FIL")).setMetricKeys(asList("lines", "ncloc")));
    assertThat(tree.getComponentsCount()).isEqualTo(4);
    tree.getComponentsList().forEach(c -> {
        assertThat(c.getMeasuresList()).extracting(m -> m.getMetric()).containsOnly("lines", "ncloc");
    });
}
Also used : BeforeClass(org.junit.BeforeClass) Issues(org.sonarqube.ws.Issues) ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) WsMeasures(org.sonarqube.ws.WsMeasures) Collections.singletonList(java.util.Collections.singletonList) WsClient(org.sonarqube.ws.client.WsClient) Arrays.asList(java.util.Arrays.asList) CollectionCondition(com.codeborne.selenide.CollectionCondition) ClassRule(org.junit.ClassRule) WsComponents(org.sonarqube.ws.WsComponents) Condition(com.codeborne.selenide.Condition) TreeWsRequest(org.sonarqube.ws.client.component.TreeWsRequest) Condition.hasText(com.codeborne.selenide.Condition.hasText) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) ItUtils.runProjectAnalysis(util.ItUtils.runProjectAnalysis) RulesPage(pageobjects.RulesPage) Test(org.junit.Test) ItUtils.xooPlugin(util.ItUtils.xooPlugin) Navigation(pageobjects.Navigation) RuleItem(pageobjects.RuleItem) Condition.or(com.codeborne.selenide.Condition.or) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) ItUtils(util.ItUtils) Orchestrator(com.sonar.orchestrator.Orchestrator) WsMeasures(org.sonarqube.ws.WsMeasures) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest) 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